Class: XML::Feed::Parser::Base
- Inherits:
-
Object
- Object
- XML::Feed::Parser::Base
- Defined in:
- lib/xml/libxml/feed/parser.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#doc ⇒ Object
readonly
Returns the value of attribute doc.
-
#validated ⇒ Object
readonly
Returns the value of attribute validated.
-
#version ⇒ Object
readonly
Returns the value of attribute version.
-
#xml ⇒ Object
readonly
Returns the value of attribute xml.
Instance Method Summary collapse
-
#initialize(version, io, auto_validate = true) ⇒ Base
constructor
A new instance of Base.
Constructor Details
#initialize(version, io, auto_validate = true) ⇒ Base
Returns a new instance of Base.
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/xml/libxml/feed/parser.rb', line 48 def initialize(version, io, auto_validate=true) @version = version case io when IO @xml = io.read io.close when StringIO @xml = io.read io.close when String @xml = io.dup else raise XML::Feed::Parser::InvalidHandle, "Must be IO, StringIO, or String object" end @xml.freeze @version.freeze @validated = false if @xml.length == 0 raise XML::Feed::Parser::InvalidHandle, "Resulting XML String must have a length greater than 0" end @doc = XML::Parser.string(@xml).parse if auto_validate validate! end end |
Instance Attribute Details
#doc ⇒ Object (readonly)
Returns the value of attribute doc.
46 47 48 |
# File 'lib/xml/libxml/feed/parser.rb', line 46 def doc @doc end |
#validated ⇒ Object (readonly)
Returns the value of attribute validated.
45 46 47 |
# File 'lib/xml/libxml/feed/parser.rb', line 45 def validated @validated end |
#version ⇒ Object (readonly)
Returns the value of attribute version.
44 45 46 |
# File 'lib/xml/libxml/feed/parser.rb', line 44 def version @version end |
#xml ⇒ Object (readonly)
Returns the value of attribute xml.
43 44 45 |
# File 'lib/xml/libxml/feed/parser.rb', line 43 def xml @xml end |