Class: GemBench::StrictVersionGem
- Inherits:
-
Object
- Object
- GemBench::StrictVersionGem
- Defined in:
- lib/gem_bench/strict_version_gem.rb
Instance Attribute Summary collapse
-
#index ⇒ Object
readonly
Returns the value of attribute index.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#relevant_lines ⇒ Object
readonly
Returns the value of attribute relevant_lines.
-
#tokenized_line ⇒ Object
readonly
Returns the value of attribute tokenized_line.
-
#valid ⇒ Object
readonly
Returns the value of attribute valid.
-
#version ⇒ Object
readonly
Returns the value of attribute version.
-
#version_type ⇒ Object
readonly
Returns the value of attribute version_type.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(name, version, version_type, valid, relevant_lines, index, tokenized_line = nil) ⇒ StrictVersionGem
constructor
A new instance of StrictVersionGem.
- #is_type?(type) ⇒ Boolean
- #to_s ⇒ Object
- #valid? ⇒ Boolean
Constructor Details
#initialize(name, version, version_type, valid, relevant_lines, index, tokenized_line = nil) ⇒ StrictVersionGem
Returns a new instance of StrictVersionGem.
22 23 24 25 26 27 28 29 30 |
# File 'lib/gem_bench/strict_version_gem.rb', line 22 def initialize(name, version, version_type, valid, relevant_lines, index, tokenized_line = nil) @name = name @version = version @version_type = version_type ? version_type.to_sym : :unknown @valid = valid @relevant_lines = relevant_lines @index = index @tokenized_line = tokenized_line # for debugging end |
Instance Attribute Details
#index ⇒ Object (readonly)
Returns the value of attribute index.
3 4 5 |
# File 'lib/gem_bench/strict_version_gem.rb', line 3 def index @index end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
3 4 5 |
# File 'lib/gem_bench/strict_version_gem.rb', line 3 def name @name end |
#relevant_lines ⇒ Object (readonly)
Returns the value of attribute relevant_lines.
3 4 5 |
# File 'lib/gem_bench/strict_version_gem.rb', line 3 def relevant_lines @relevant_lines end |
#tokenized_line ⇒ Object (readonly)
Returns the value of attribute tokenized_line.
3 4 5 |
# File 'lib/gem_bench/strict_version_gem.rb', line 3 def tokenized_line @tokenized_line end |
#valid ⇒ Object (readonly)
Returns the value of attribute valid.
3 4 5 |
# File 'lib/gem_bench/strict_version_gem.rb', line 3 def valid @valid end |
#version ⇒ Object (readonly)
Returns the value of attribute version.
3 4 5 |
# File 'lib/gem_bench/strict_version_gem.rb', line 3 def version @version end |
#version_type ⇒ Object (readonly)
Returns the value of attribute version_type.
3 4 5 |
# File 'lib/gem_bench/strict_version_gem.rb', line 3 def version_type @version_type end |
Class Method Details
.from_line(all_lines, line, index, opts = {}) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/gem_bench/strict_version_gem.rb', line 6 def from_line(all_lines, line, index, opts = {}) tokenized_line = GemfileLineTokenizer.new(all_lines, line, index) return unless tokenized_line.is_gem new( tokenized_line.name, tokenized_line.version, tokenized_line.version_type, tokenized_line.valid, tokenized_line.relevant_lines, tokenized_line.index, (opts[:debug] == true) ? tokenized_line : nil, ) end |
Instance Method Details
#is_type?(type) ⇒ Boolean
36 37 38 |
# File 'lib/gem_bench/strict_version_gem.rb', line 36 def is_type?(type) version_type == type.to_sym end |
#to_s ⇒ Object
40 41 42 43 44 45 46 47 48 |
# File 'lib/gem_bench/strict_version_gem.rb', line 40 def to_s <<~EOS Gem: #{name} Line Number: #{index} Version: #{version.inspect} Relevant Gemfile Lines: #{relevant_lines.join("\n")} EOS end |
#valid? ⇒ Boolean
32 33 34 |
# File 'lib/gem_bench/strict_version_gem.rb', line 32 def valid? valid end |