Module: Synaptic4r::Utils

Included in:
Client, Rest::InstanceMethods
Defined in:
lib/synaptic4r/rest.rb

Instance Method Summary collapse

Instance Method Details

#create_timestampObject

.….….….….….….….….….….….….….….….….….….….….….….….….……



22
23
24
# File 'lib/synaptic4r/rest.rb', line 22

def create_timestamp()
  Time.now().httpdate()
end

#read_file(file, offset, length) ⇒ Object

.….….….….….….….….….….….….….….….….….….….….….….….….……



27
28
29
# File 'lib/synaptic4r/rest.rb', line 27

def read_file(file, offset, length)
  IO.read(file, length, offset)
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

.….….….….….….….….….….….….….….….….….….….….….….….….……

Returns:

  • (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