Class: CultureGrid::Doc
- Inherits:
-
Hashie::Mash
- Object
- Hashie::Mash
- CultureGrid::Doc
- Defined in:
- lib/culturegrid.rb
Instance Method Summary collapse
-
#initialize(d = nil, default = nil, &blk) ⇒ Doc
constructor
A new instance of Doc.
Constructor Details
#initialize(d = nil, default = nil, &blk) ⇒ Doc
Returns a new instance of Doc.
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/culturegrid.rb', line 47 def initialize(d = nil, default = nil, &blk) hash = {} if d && d.children d.children.each do |prop| if prop.attributes["name"] case prop.name when "arr" hash[prop.attributes["name"].value] = prop.children.collect{|c| c.text} else if prop.children hash[prop.attributes["name"].value] = prop.children.text else hash[prop.attributes["name"].value] = prop.text end end end end end hash["id"] = hash["aggregator.internal.id"] hash["title"] = hash["dc.title"].first rescue "Untitled" super(hash, default, &blk) rescue super({}) end |