Class: Minitext::Message

Inherits:
Object
  • Object
show all
Defined in:
lib/minitext/message.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(params) ⇒ Message

Returns a new instance of Message.



5
6
7
8
9
# File 'lib/minitext/message.rb', line 5

def initialize(params)
  params.each do |attr, value|
    self.public_send("#{attr}=", value)
  end
end

Instance Attribute Details

#bodyObject

Returns the value of attribute body.



3
4
5
# File 'lib/minitext/message.rb', line 3

def body
  @body
end

#fromObject

Returns the value of attribute from.



3
4
5
# File 'lib/minitext/message.rb', line 3

def from
  @from
end

#gatewayObject

Returns the value of attribute gateway.



3
4
5
# File 'lib/minitext/message.rb', line 3

def gateway
  @gateway
end

#toObject

Returns the value of attribute to.



3
4
5
# File 'lib/minitext/message.rb', line 3

def to
  @to
end

Instance Method Details

#deliverObject



15
16
17
18
# File 'lib/minitext/message.rb', line 15

def deliver
  return false unless valid?
  !!gateway.deliver(self)
end

#deliver!Object



11
12
13
# File 'lib/minitext/message.rb', line 11

def deliver!
  deliver || raise_errors
end

#valid?Boolean

Returns:

  • (Boolean)


20
21
22
# File 'lib/minitext/message.rb', line 20

def valid?
  valid_param?(from) && valid_param?(to) && valid_param?(body) && !gateway.nil?
end