Class: Synaptic4r::StorageObjectList
- Defined in:
- lib/synaptic4r/result.rb
Instance Attribute Summary
Attributes inherited from Result
#headers, #http_request, #payload, #result, #sign, #url
Instance Method Summary collapse
-
#extract_attrs(a, is_listable) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….……
-
#initialize(args) ⇒ StorageObjectList
constructor
.….….….….….….….….….….….….….….….….….….….….….….….….……
-
#metadata(ols, tag, is_listable = false) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….……
-
#objs ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….……
-
#oids(ols) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….……
-
#print ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….……
Methods inherited from Result
#extract_header, #method_missing, #stringify_array, #stringify_hash
Constructor Details
#initialize(args) ⇒ StorageObjectList
.….….….….….….….….….….….….….….….….….….….….….….….….……
211 212 213 214 215 216 |
# File 'lib/synaptic4r/result.rb', line 211 def initialize(args) super if args[:result] @objs = REXML::Document.new(args[:result].net_http_res.body).root end end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Synaptic4r::Result
Instance Method Details
#extract_attrs(a, is_listable) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….……
251 252 253 254 255 256 |
# File 'lib/synaptic4r/result.rb', line 251 def extract_attrs(a,is_listable) add_item = if is_listable a.elements.to_a('Listable').first.text.eql?('true') else; true; end add_item ? {a.elements.to_a('Name').first.text => a.elements.to_a('Value').first.text} : nil end |
#metadata(ols, tag, is_listable = false) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….……
242 243 244 245 246 247 248 |
# File 'lib/synaptic4r/result.rb', line 242 def (ols, tag, is_listable=false) = ols.map{|o| o.elements.to_a(tag)} .map{|a| a.empty? ? nil : a.first.elements.to_a.inject({}) do |h,s| a = extract_attrs(s, is_listable) a.nil? ? h : h.update(a) end}.compact end |
#objs ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….……
259 260 261 |
# File 'lib/synaptic4r/result.rb', line 259 def objs @objs.nil? ? [] : @objs.elements.to_a('Object') end |
#oids(ols) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….……
237 238 239 |
# File 'lib/synaptic4r/result.rb', line 237 def oids(ols) ols.map{|o| o.elements.to_a('ObjectID').first.text} end |
#print ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….……
219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 |
# File 'lib/synaptic4r/result.rb', line 219 def print ols = objs oid = oids(ols) = (ols, 'SystemMetadataList') = (ols, 'UserMetadataList', true) unless .empty? fmt = "%-40s %-10s %-s\n" fmt % ['Metadata', 'Type', 'OID'] + .inject("") do |r,e| t = e['type'] r += fmt % [.shift.keys.join(','), (t.eql?('regular') ? 'file' : t), e['objectid']] end else "OID\n" + oid.join("\n").chomp unless oid.empty? end end |