Class: OPML::Outline
- Inherits:
-
Object
- Object
- OPML::Outline
- Defined in:
- lib/opmlparser.rb
Defined Under Namespace
Class Method Summary collapse
- .parse(xml) ⇒ Object (also: load)
- .read(path) ⇒ Object (also: load_file)
Instance Method Summary collapse
- #[](index) ⇒ Object
- #category ⇒ Object
- #created ⇒ Object
- #description ⇒ Object
- #each(&blk) ⇒ Object
- #htmlUrl ⇒ Object (also: #html_url)
-
#initialize(h) ⇒ Outline
constructor
A new instance of Outline.
- #language ⇒ Object
- #meta ⇒ Object
-
#size ⇒ Object
(also: #length)
array delegates for outline children todo/fix: check if outline can be nil? !!!!.
- #text ⇒ Object
- #title ⇒ Object
- #type ⇒ Object
- #url ⇒ Object
- #version ⇒ Object
- #xmlUrl ⇒ Object (also: #xml_url)
Constructor Details
#initialize(h) ⇒ Outline
Returns a new instance of Outline.
128 129 130 |
# File 'lib/opmlparser.rb', line 128 def initialize( h ) @h = h end |
Class Method Details
.parse(xml) ⇒ Object Also known as: load
75 76 77 |
# File 'lib/opmlparser.rb', line 75 def self.parse( xml ) Parser.new( xml ).parse end |
.read(path) ⇒ Object Also known as: load_file
78 79 80 81 |
# File 'lib/opmlparser.rb', line 78 def self.read( path ) xml = File.open( path, 'r:utf-8' ) { |f| f.read } parse( xml ) end |
Instance Method Details
#[](index) ⇒ Object
132 133 134 135 136 137 138 139 140 |
# File 'lib/opmlparser.rb', line 132 def [](index) if index.is_a?(Integer) h = @h['outline'][index] h = Outline.new( h ) if h.is_a?(Hash) ## allow "on-demand" use/wrapping too - why? why not? h else ## assume index is a text key @h[ index ] end end |
#category ⇒ Object
161 |
# File 'lib/opmlparser.rb', line 161 def category() @h['category']; end |
#created ⇒ Object
158 |
# File 'lib/opmlparser.rb', line 158 def created() @h['created']; end |
#description ⇒ Object
162 |
# File 'lib/opmlparser.rb', line 162 def description() @h['description']; end |
#each(&blk) ⇒ Object
147 |
# File 'lib/opmlparser.rb', line 147 def each( &blk ) @h['outline'].each( &blk ); end |
#htmlUrl ⇒ Object Also known as: html_url
155 |
# File 'lib/opmlparser.rb', line 155 def htmlUrl() @h['htmlUrl']; end |
#language ⇒ Object
163 |
# File 'lib/opmlparser.rb', line 163 def language() @h['language']; end |
#meta ⇒ Object
166 |
# File 'lib/opmlparser.rb', line 166 def () @h['meta']; end |
#size ⇒ Object Also known as: length
array delegates for outline children
todo/fix: check if outline can be nil? !!!!
144 |
# File 'lib/opmlparser.rb', line 144 def size() @h['outline'].size; end |
#text ⇒ Object
150 |
# File 'lib/opmlparser.rb', line 150 def text() @h['text']; end |
#title ⇒ Object
159 |
# File 'lib/opmlparser.rb', line 159 def title() @h['title']; end |
#type ⇒ Object
160 |
# File 'lib/opmlparser.rb', line 160 def type() @h['type']; end |
#url ⇒ Object
154 |
# File 'lib/opmlparser.rb', line 154 def url() @h['url']; end |
#version ⇒ Object
164 |
# File 'lib/opmlparser.rb', line 164 def version() @h['version']; end |
#xmlUrl ⇒ Object Also known as: xml_url
151 |
# File 'lib/opmlparser.rb', line 151 def xmlUrl() @h['xmlUrl']; end |