Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: extract ReVIEW::Location #1308

Merged
merged 1 commit into from
Jun 2, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 1 addition & 23 deletions lib/review/compiler.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,32 +9,10 @@
require 'review/extentions'
require 'review/preprocessor'
require 'review/exception'
require 'review/location'
require 'strscan'

module ReVIEW
class Location
def initialize(filename, f)
@filename = filename
@f = f
end

attr_reader :filename

def lineno
@f.lineno
end

def string
begin
"#{@filename}:#{@f.lineno}"
rescue
"#{@filename}:nil"
end
end

alias_method :to_s, :string
end

class Compiler
def initialize(strategy)
@strategy = strategy
Expand Down
32 changes: 32 additions & 0 deletions lib/review/location.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Copyright (c) 2009-2019 Minero Aoki, Kenshi Muto, Masayoshi Takahashi
# Copyright (c) 2002-2007 Minero Aoki
#
# This program is free software.
# You can distribute or modify this program under the terms of
# the GNU LGPL, Lesser General Public License version 2.1.
#

module ReVIEW
class Location
def initialize(filename, f)
@filename = filename
@f = f
end

attr_reader :filename

def lineno
@f.lineno
end

def string
begin
"#{@filename}:#{@f.lineno}"
rescue
"#{@filename}:nil"
end
end

alias_method :to_s, :string
end
end