Class: OPML::Outline

Inherits:
Object
  • Object
show all
Defined in:
lib/opmlparser.rb

Defined Under Namespace

Classes: Meta, Parser

Class Method Summary collapse

Instance Method Summary collapse

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

#categoryObject



161
# File 'lib/opmlparser.rb', line 161

def category()     @h['category']; end

#createdObject



158
# File 'lib/opmlparser.rb', line 158

def created()      @h['created']; end

#descriptionObject



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

#htmlUrlObject Also known as: html_url



155
# File 'lib/opmlparser.rb', line 155

def htmlUrl()      @h['htmlUrl']; end

#languageObject



163
# File 'lib/opmlparser.rb', line 163

def language()     @h['language']; end

#metaObject



166
# File 'lib/opmlparser.rb', line 166

def meta()  @h['meta']; end

#sizeObject 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

#textObject



150
# File 'lib/opmlparser.rb', line 150

def text()         @h['text'];   end

#titleObject



159
# File 'lib/opmlparser.rb', line 159

def title()        @h['title']; end

#typeObject



160
# File 'lib/opmlparser.rb', line 160

def type()         @h['type']; end

#urlObject



154
# File 'lib/opmlparser.rb', line 154

def url()          @h['url']; end

#versionObject



164
# File 'lib/opmlparser.rb', line 164

def version()      @h['version']; end

#xmlUrlObject Also known as: xml_url



151
# File 'lib/opmlparser.rb', line 151

def xmlUrl()       @h['xmlUrl']; end