Class: Smess::Sms

Inherits:
Object
  • Object
show all
Defined in:
lib/smess/sms.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ Sms

Returns a new instance of Sms.



6
7
8
9
10
11
12
# File 'lib/smess/sms.rb', line 6

def initialize(*args)
  opts = args.first || {}
  @to = opts.fetch(:to, nil)
  @message = opts.fetch(:message, "")
  @originator = opts.fetch(:originator, nil)
  @output = opts.fetch(:output, :auto).to_sym
end

Instance Attribute Details

#messageObject

Returns the value of attribute message.



4
5
6
# File 'lib/smess/sms.rb', line 4

def message
  @message
end

#originatorObject

Returns the value of attribute originator.



4
5
6
# File 'lib/smess/sms.rb', line 4

def originator
  @originator
end

#outputObject

Returns the value of attribute output.



4
5
6
# File 'lib/smess/sms.rb', line 4

def output
  @output
end

#resultsObject

Returns the value of attribute results.



4
5
6
# File 'lib/smess/sms.rb', line 4

def results
  @results
end

#toObject

Returns the value of attribute to.



4
5
6
# File 'lib/smess/sms.rb', line 4

def to
  @to
end

Instance Method Details

#deliverObject



14
15
16
17
18
# File 'lib/smess/sms.rb', line 14

def deliver
  out = Smess.named_output_instance(output)
  out.sms = self
  self.results = {sent_with: output}.merge(out.deliver)
end

#delivered?Boolean

Returns:

  • (Boolean)


20
21
22
# File 'lib/smess/sms.rb', line 20

def delivered?
  results[:response_code] == "0"
end