Sha256: 2b3d38806e06a2412b73a0ef89b21b03be2eb1f5cdbd49750d8333b3d502cd35

Contents?: true

Size: 1.75 KB

Versions: 2

Compression:

Stored size: 1.75 KB

Contents

require 'atom/feed'

module Sword2Ruby
  
  #Extend existing Atom::Service with Sword methods
  class ::Atom::Feed < ::Atom::Element
    
    #This method returns an array of Atom::Categories of the original deposit (usually contained in the Sword Statement Atom Feed),
    #or an empty array [ ] if none are defined.
    #
    #For more information, see the Sword2 specification: {section 11.4. "Atom Serialisation"}[http://sword-app.svn.sourceforge.net/viewvc/sword-app/spec/tags/sword-2.0/SWORDProfile.html?revision=377#statement_atom].
    def sword_state_categories
      Utility.find_elements_by_scheme(categories, "http://purl.org/net/sword/terms/state")
    end

    #This method returns the string href of the <sword:state> tag (usually contained in the Sword Statement Atom Feed),
    #or nil if it is not defined.
    #
    #For more information, see the Sword2 specification: {section 11.1.2. "sword:state"}[http://sword-app.svn.sourceforge.net/viewvc/sword-app/spec/tags/sword-2.0/SWORDProfile.html?revision=377#statement_predicates_state].
    def sword_state
      Utility.find_element_attribute_value(extensions, "sword:state", "href")
    end

    #This method returns the string value of the <sword:stateDescription> tag (usually contained in the Sword Statement Atom Feed),
    #or nil if it is not defined.
    #
    #For more information, see the Sword2 specification: {section 11.1.7. "sword:state"}[http://sword-app.svn.sourceforge.net/viewvc/sword-app/spec/tags/sword-2.0/SWORDProfile.html?revision=377#statement_predicates_description].
    def sword_state_description
      swordstate = Utility.find_element_by_name(extensions, "sword:state")
      swordstate.nil? ? nil : Utility.find_element_text(swordstate.elements, "sword:stateDescription")
    end
    
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
sword2ruby-1.0.1 lib/sword2ruby/feed.rb
sword2ruby-1.0.0 lib/sword2ruby/feed.rb