Class: Ape::Collection
- Inherits:
-
Object
- Object
- Ape::Collection
- Defined in:
- lib/ape/collection.rb
Instance Attribute Summary collapse
-
#accept ⇒ Object
readonly
Returns the value of attribute accept.
-
#href ⇒ Object
readonly
Returns the value of attribute href.
-
#title ⇒ Object
readonly
Returns the value of attribute title.
Instance Method Summary collapse
-
#catses ⇒ Object
the name is supposed to suggest multiple instances of “categories”.
-
#initialize(input, doc_uri = nil) ⇒ Collection
constructor
A new instance of Collection.
- #to_s ⇒ Object
- #to_str ⇒ Object
Constructor Details
#initialize(input, doc_uri = nil) ⇒ Collection
Returns a new instance of Collection.
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/ape/collection.rb', line 9 def initialize(input, doc_uri = nil) @input = input @accept = [] @title = REXML::XPath.first(input, './atom:title', Names::XmlNamespaces) # sigh, RNC validation *should* take care of this raise(SyntaxError, "Collection is missing required 'atom:title'") unless @title @title = @title.texts.join if doc_uri uris = AtomURI.new(doc_uri) @href = uris.absolutize(input.attributes['href'], input) else @href = input.attributes['href'] end # now we have to go looking for the accept @accept = [] REXML::XPath.each(input, './app:accept', Names::XmlNamespaces) do |a| @accept << a.texts.join end @accept = [ Names::AtomEntryMediaType ] if @accept.empty? end |
Instance Attribute Details
#accept ⇒ Object (readonly)
Returns the value of attribute accept.
7 8 9 |
# File 'lib/ape/collection.rb', line 7 def accept @accept end |
#href ⇒ Object (readonly)
Returns the value of attribute href.
7 8 9 |
# File 'lib/ape/collection.rb', line 7 def href @href end |
#title ⇒ Object (readonly)
Returns the value of attribute title.
7 8 9 |
# File 'lib/ape/collection.rb', line 7 def title @title end |
Instance Method Details
#catses ⇒ Object
the name is supposed to suggest multiple instances of “categories”
43 44 45 |
# File 'lib/ape/collection.rb', line 43 def catses REXML::XPath.match(@input, './app:categories', Names::XmlNamespaces) end |
#to_s ⇒ Object
34 35 36 |
# File 'lib/ape/collection.rb', line 34 def to_s @input.to_s end |
#to_str ⇒ Object
38 39 40 |
# File 'lib/ape/collection.rb', line 38 def to_str to_s end |