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, source = nil) ⇒ SdlParser
constructor
A new instance of SdlParser.
- #parse ⇒ Object
Constructor Details
#initialize(type, contents, source = nil) ⇒ SdlParser
Returns a new instance of SdlParser.
8 9 10 11 12 |
# File 'lib/sdl_parser.rb', line 8 def initialize(type, contents, source = nil) @contents = contents @type = type || "runtime" @source = source end |
Instance Attribute Details
#contents ⇒ Object (readonly)
Returns the value of attribute contents.
6 7 8 |
# File 'lib/sdl_parser.rb', line 6 def contents @contents end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
6 7 8 |
# File 'lib/sdl_parser.rb', line 6 def type @type end |
Instance Method Details
#dependencies ⇒ Object
14 15 16 17 18 19 20 21 22 23 |
# File 'lib/sdl_parser.rb', line 14 def dependencies parse.children("dependency").inject([]) do |deps, dep| deps.push(Bibliothecary::Dependency.new( name: dep.value, requirement: dep.attribute("version") || ">= 0", type: type, source: @source )) end.uniq end |
#parse ⇒ Object
25 26 27 |
# File 'lib/sdl_parser.rb', line 25 def parse SDL4R.read(contents) end |