Class: LittleSMS::Responce

Inherits:
Object
  • Object
show all
Defined in:
lib/little_sms/responce.rb

Instance Method Summary collapse

Constructor Details

#initialize(json) ⇒ Responce

Returns a new instance of Responce.



5
6
7
# File 'lib/little_sms/responce.rb', line 5

def initialize(json)
  @json = json.symbolize_keys
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name, *args) ⇒ Object



25
26
27
28
29
30
31
# File 'lib/little_sms/responce.rb', line 25

def method_missing(name, *args)
  unless args.empty?
    super
  else
    @json[name] || super
  end
end

Instance Method Details

#errorObject



17
18
19
# File 'lib/little_sms/responce.rb', line 17

def error
  @json[:error] if error?
end

#error?Boolean

Returns:

  • (Boolean)


13
14
15
# File 'lib/little_sms/responce.rb', line 13

def error?
  @json[:status] == "error"
end

#messageObject



21
22
23
# File 'lib/little_sms/responce.rb', line 21

def message
  @json[:message] if error?
end

#respond_to?(method) ⇒ Boolean

Returns:

  • (Boolean)


33
34
35
# File 'lib/little_sms/responce.rb', line 33

def respond_to?(method)
  @json.has_key?(method) || super
end

#success?Boolean

Returns:

  • (Boolean)


9
10
11
# File 'lib/little_sms/responce.rb', line 9

def success?
  @json[:status] == "success"
end