Class: Indexer::Engine
Overview
The Engine class models the name and version of a the language necessray to run the software.
Instance Attribute Summary collapse
-
#name ⇒ Object
The name of the package that causes the conflict.
-
#version ⇒ Object
The versions constraint of the conflicting package.
Class Method Summary collapse
-
.parse(data) ⇒ Object
Parse
data
into a Dependency instance. - .parse_array(data) ⇒ Object private
- .parse_hash(data) ⇒ Object private
- .parse_string(data) ⇒ Object private
Instance Method Summary collapse
Methods inherited from Model
#[], #[]=, attr_reader, attr_writer, #initialize, #initialize_attributes, #key?, #merge!, #method_missing, #store, #to_yaml, #validate
Constructor Details
This class inherits a constructor from Indexer::Model
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Indexer::Model
Instance Attribute Details
#name ⇒ Object
The name of the package that causes the conflict.
Yea it's ALWAYS THEIR fault ;-)
55 56 57 |
# File 'lib/indexer/components/engine.rb', line 55 def name @name end |
#version ⇒ Object
The versions constraint of the conflicting package. This is used when only certain versions of the package are the problem.
69 70 71 |
# File 'lib/indexer/components/engine.rb', line 69 def version @version end |
Class Method Details
.parse(data) ⇒ Object
Parse data
into a Dependency instance.
TODO: What about respond_to?(:to_str) for String, etc.
11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/indexer/components/engine.rb', line 11 def self.parse(data) case data when Engine data when String parse_string(data) when Array parse_array(data) when Hash parse_hash(data) else raise(ValidationError, "Engine") end end |
.parse_array(data) ⇒ Object (private)
37 38 39 40 |
# File 'lib/indexer/components/engine.rb', line 37 def self.parse_array(data) name, version = *data new(:name=>name, :version=>version) end |
.parse_hash(data) ⇒ Object (private)
44 45 46 |
# File 'lib/indexer/components/engine.rb', line 44 def self.parse_hash(data) new(data) end |
.parse_string(data) ⇒ Object (private)
30 31 32 33 |
# File 'lib/indexer/components/engine.rb', line 30 def self.parse_string(data) name, version = data.split(/\s+/) new(:name=>name, :version=>version) end |
Instance Method Details
#to_h ⇒ Object
81 82 83 |
# File 'lib/indexer/components/engine.rb', line 81 def to_h {'name'=>name, 'version'=>version.to_s} end |