Class: SdlParser
- Inherits:
-
Object
- Object
- SdlParser
- Defined in:
- lib/sdl_parser.rb
Instance Attribute Summary collapse
-
#contents ⇒ Object
readonly
Returns the value of attribute contents.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
- #dependencies ⇒ Object
-
#initialize(type, contents) ⇒ SdlParser
constructor
A new instance of SdlParser.
- #parse ⇒ Object
Constructor Details
#initialize(type, contents) ⇒ SdlParser
Returns a new instance of SdlParser.
5 6 7 8 |
# File 'lib/sdl_parser.rb', line 5 def initialize(type, contents) @contents = contents @type = type || 'runtime' end |
Instance Attribute Details
#contents ⇒ Object (readonly)
Returns the value of attribute contents.
4 5 6 |
# File 'lib/sdl_parser.rb', line 4 def contents @contents end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
4 5 6 |
# File 'lib/sdl_parser.rb', line 4 def type @type end |
Instance Method Details
#dependencies ⇒ Object
10 11 12 13 14 15 16 17 18 |
# File 'lib/sdl_parser.rb', line 10 def dependencies parse.children('dependency').inject([]) do |deps, dep| deps.push({ name: dep.value, requirement: dep.attribute('version') || ">= 0", type: type }) end.uniq end |
#parse ⇒ Object
20 21 22 |
# File 'lib/sdl_parser.rb', line 20 def parse SDL4R::read(contents) end |