Class: Enklawa::Api::Response
- Inherits:
-
Object
- Object
- Enklawa::Api::Response
- Defined in:
- lib/enklawa/api/response.rb
Instance Attribute Summary collapse
-
#phone ⇒ Object
Returns the value of attribute phone.
-
#radio ⇒ Object
Returns the value of attribute radio.
-
#skype ⇒ Object
Returns the value of attribute skype.
Instance Method Summary collapse
- #<<(program) ⇒ Object
- #add_category(category) ⇒ Object
- #add_thread(category) ⇒ Object
-
#initialize ⇒ Response
constructor
A new instance of Response.
- #programs ⇒ Object
- #save(filename) ⇒ Object
- #to_h ⇒ Object
Constructor Details
#initialize ⇒ Response
Returns a new instance of Response.
6 7 8 9 10 |
# File 'lib/enklawa/api/response.rb', line 6 def initialize @programs = [] @threads = [] @categories = [] end |
Instance Attribute Details
#phone ⇒ Object
Returns the value of attribute phone.
4 5 6 |
# File 'lib/enklawa/api/response.rb', line 4 def phone @phone end |
#radio ⇒ Object
Returns the value of attribute radio.
4 5 6 |
# File 'lib/enklawa/api/response.rb', line 4 def radio @radio end |
#skype ⇒ Object
Returns the value of attribute skype.
4 5 6 |
# File 'lib/enklawa/api/response.rb', line 4 def skype @skype end |
Instance Method Details
#<<(program) ⇒ Object
16 17 18 |
# File 'lib/enklawa/api/response.rb', line 16 def <<(program) @programs << program end |
#add_category(category) ⇒ Object
20 21 22 |
# File 'lib/enklawa/api/response.rb', line 20 def add_category(category) @categories << category end |
#add_thread(category) ⇒ Object
24 25 26 |
# File 'lib/enklawa/api/response.rb', line 24 def add_thread(category) @threads << category end |
#programs ⇒ Object
12 13 14 |
# File 'lib/enklawa/api/response.rb', line 12 def programs @programs end |
#save(filename) ⇒ Object
41 42 43 44 |
# File 'lib/enklawa/api/response.rb', line 41 def save(filename) json = JSON.pretty_generate(to_h) File.open(filename, "w") { |f| f.write json } end |
#to_h ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/enklawa/api/response.rb', line 28 def to_h { version: VERSION, skype: skype, build: Time.now.to_s, phone: phone, radio: radio, forum: @threads.map(&:to_h), categories: @categories.map(&:to_h), programs: @programs.map(&:to_h) } end |