Class: Wrxer::Parser
- Inherits:
-
Object
- Object
- Wrxer::Parser
- Defined in:
- lib/wrxer/parser.rb
Instance Attribute Summary collapse
-
#document ⇒ Object
readonly
Returns the value of attribute document.
-
#filename ⇒ Object
readonly
Returns the value of attribute filename.
-
#xml_document ⇒ Object
readonly
Returns the value of attribute xml_document.
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(filename) ⇒ Parser
constructor
A new instance of Parser.
- #inspect ⇒ Object
Constructor Details
#initialize(filename) ⇒ Parser
Returns a new instance of Parser.
4 5 6 7 8 9 10 |
# File 'lib/wrxer/parser.rb', line 4 def initialize(filename) @filename = filename File.open(filename) do |file| @xml_document = Nokogiri::XML(file) end end |
Instance Attribute Details
#document ⇒ Object (readonly)
Returns the value of attribute document.
3 4 5 |
# File 'lib/wrxer/parser.rb', line 3 def document @document end |
#filename ⇒ Object (readonly)
Returns the value of attribute filename.
3 4 5 |
# File 'lib/wrxer/parser.rb', line 3 def filename @filename end |
#xml_document ⇒ Object (readonly)
Returns the value of attribute xml_document.
3 4 5 |
# File 'lib/wrxer/parser.rb', line 3 def xml_document @xml_document end |
Instance Method Details
#call ⇒ Object
12 13 14 |
# File 'lib/wrxer/parser.rb', line 12 def call @document ||= Document.call(@xml_document) end |
#inspect ⇒ Object
16 17 18 |
# File 'lib/wrxer/parser.rb', line 16 def inspect "#<#{self.class}:0x#{self.object_id.to_s(16)}> { filename: #{@filename.to_path}, xml_document: #{@xml_document.class} }" end |