Class: ShelbyArena::Response::Base
- Inherits:
-
Object
- Object
- ShelbyArena::Response::Base
show all
- Defined in:
- lib/shelby_arena/response/base.rb
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize(data) ⇒ Base
Returns a new instance of Base.
14
15
16
|
# File 'lib/shelby_arena/response/base.rb', line 14
def initialize(data)
@data = data
end
|
Instance Attribute Details
#data ⇒ Object
Returns the value of attribute data.
4
5
6
|
# File 'lib/shelby_arena/response/base.rb', line 4
def data
@data
end
|
Class Method Details
6
7
8
|
# File 'lib/shelby_arena/response/base.rb', line 6
def self.format(data)
new(data).format
end
|
10
11
12
|
# File 'lib/shelby_arena/response/base.rb', line 10
def self.format_list(data)
new(data).format_list
end
|
Instance Method Details
#date_parse(string) ⇒ Object
49
50
51
52
53
|
# File 'lib/shelby_arena/response/base.rb', line 49
def date_parse(string)
return DateTime.parse(string) if string
nil
end
|
27
28
29
30
31
32
33
34
35
|
# File 'lib/shelby_arena/response/base.rb', line 27
def format
return nil if data.nil?
if data.is_a?(Array)
data.map { |item| format_single(item) }
else
format_single(data)
end
end
|
18
19
20
21
22
23
24
25
|
# File 'lib/shelby_arena/response/base.rb', line 18
def format_list
res = format
return [] if res.nil?
return [res] if res.is_a?(Hash)
res
end
|
#to_boolean(string) ⇒ Object
45
46
47
|
# File 'lib/shelby_arena/response/base.rb', line 45
def to_boolean(string)
string.downcase == 'true'
end
|
#to_h(dict, data) ⇒ Object
37
38
39
40
41
42
43
|
# File 'lib/shelby_arena/response/base.rb', line 37
def to_h(dict, data)
return {} if data.nil?
dict.each_with_object({}) do |(l, r), object|
object[l] = data[r]
end
end
|