Module: Synaptic4r::Utils
- Included in:
- Client, StorageRest::InstanceMethods
- Defined in:
- lib/synaptic4r/rest.rb
Instance Method Summary collapse
-
#create_timestamp ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….……
-
#read_file(file, offset, length) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….……
-
#symbolize(e) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….……
-
#unary_args_given?(unary_args, args) ⇒ Boolean
.….….….….….….….….….….….….….….….….….….….….….….….….……
Instance Method Details
#create_timestamp ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….……
22 23 24 |
# File 'lib/synaptic4r/rest.rb', line 22 def () Time.now().httpdate() end |
#read_file(file, offset, length) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….……
27 28 29 30 31 32 33 34 35 |
# File 'lib/synaptic4r/rest.rb', line 27 def read_file(file, offset, length) case file when String IO.read(file, length, offset) else file.seek(offset) file.read(length) end end |
#symbolize(e) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….……
13 14 15 16 17 18 19 |
# File 'lib/synaptic4r/rest.rb', line 13 def symbolize(e) if e.kind_of?(Hash) e.inject({}){|h, (k,v)| h.update(k.to_sym => v)} elsif e.kind_of?(Array) e.map{|v| v.to_sym} end end |
#unary_args_given?(unary_args, args) ⇒ Boolean
.….….….….….….….….….….….….….….….….….….….….….….….….……
8 9 10 |
# File 'lib/synaptic4r/rest.rb', line 8 def unary_args_given?(unary_args, args) unary_args.each{|a| raise ArgumentError, "Required argument '#{a}' is missing." unless args.include?(a)} end |