Class: Synaptic4r::Result
- Inherits:
-
Object
- Object
- Synaptic4r::Result
- Defined in:
- lib/synaptic4r/result.rb
Direct Known Subclasses
Acl, Download, ShareableUrl, StorageObject, StorageObjectList, SystemMetadata, Tags, UserMetadata, Versions
Instance Attribute Summary collapse
-
#headers ⇒ Object
readonly
.….….….….….….….….….….….….….….….….….….….….….….….….……
-
#http_request ⇒ Object
readonly
.….….….….….….….….….….….….….….….….….….….….….….….….……
-
#payload ⇒ Object
readonly
.….….….….….….….….….….….….….….….….….….….….….….….….……
-
#result ⇒ Object
readonly
.….….….….….….….….….….….….….….….….….….….….….….….….……
-
#sign ⇒ Object
readonly
.….….….….….….….….….….….….….….….….….….….….….….….….……
-
#url ⇒ Object
readonly
.….….….….….….….….….….….….….….….….….….….….….….….….……
Instance Method Summary collapse
-
#extract_header(args, header) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….……
-
#initialize(args) ⇒ Result
constructor
.….….….….….….….….….….….….….….….….….….….….….….….….……
-
#method_missing(meth, *args, &blk) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….….….
-
#print ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….……
-
#stringify_array(a) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….……
-
#stringify_hash(h) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….……
Constructor Details
#initialize(args) ⇒ Result
.….….….….….….….….….….….….….….….….….….….….….….….….……
11 12 13 14 15 16 17 18 |
# File 'lib/synaptic4r/result.rb', line 11 def initialize(args) @http_request = args[:http_request] @headers = args[:headers] @url = args[:url] @sign = args[:sign] @payload = args[:payload] @result = {} end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(meth, *args, &blk) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….….….
25 26 27 28 29 30 31 |
# File 'lib/synaptic4r/result.rb', line 25 def method_missing(meth, *args, &blk) if result.kind_of?(Hash) and result.keys.include?(meth) result[meth] else result.send(meth, *args, &blk) end end |
Instance Attribute Details
#headers ⇒ Object (readonly)
.….….….….….….….….….….….….….….….….….….….….….….….….……
8 9 10 |
# File 'lib/synaptic4r/result.rb', line 8 def headers @headers end |
#http_request ⇒ Object (readonly)
.….….….….….….….….….….….….….….….….….….….….….….….….……
8 9 10 |
# File 'lib/synaptic4r/result.rb', line 8 def http_request @http_request end |
#payload ⇒ Object (readonly)
.….….….….….….….….….….….….….….….….….….….….….….….….……
8 9 10 |
# File 'lib/synaptic4r/result.rb', line 8 def payload @payload end |
#result ⇒ Object (readonly)
.….….….….….….….….….….….….….….….….….….….….….….….….……
8 9 10 |
# File 'lib/synaptic4r/result.rb', line 8 def result @result end |
#sign ⇒ Object (readonly)
.….….….….….….….….….….….….….….….….….….….….….….….….……
8 9 10 |
# File 'lib/synaptic4r/result.rb', line 8 def sign @sign end |
#url ⇒ Object (readonly)
.….….….….….….….….….….….….….….….….….….….….….….….….……
8 9 10 |
# File 'lib/synaptic4r/result.rb', line 8 def url @url end |
Instance Method Details
#extract_header(args, header) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….……
34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/synaptic4r/result.rb', line 34 def extract_header(args, header) headers = args[:result].headers[header] if headers headers.split(/,\s+/).map{|a| a.strip}.inject({}) do |r,a| v = a.split('=') v << 'N/A' if v.length < 2 r.update(v.first => v.last) end else {} end end |
#print ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….……
21 22 |
# File 'lib/synaptic4r/result.rb', line 21 def print end |
#stringify_array(a) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….……
54 55 56 |
# File 'lib/synaptic4r/result.rb', line 54 def stringify_array(a) a.split(/,\s+/).sort.inject(""){|s,t| s += "#{t}, "}.chomp(', ') if a end |
#stringify_hash(h) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….……
48 49 50 |
# File 'lib/synaptic4r/result.rb', line 48 def stringify_hash(h) h.inject(""){|r,(u,a)| r += " #{u}=#{a}\n"} end |