Class: IletiMerkezi::Message
- Inherits:
-
Object
- Object
- IletiMerkezi::Message
- Defined in:
- lib/ileti_merkezi/message.rb
Overview
Message
Instance Attribute Summary collapse
-
#phones ⇒ Object
readonly
Returns the value of attribute phones.
-
#text ⇒ Object
readonly
Returns the value of attribute text.
Instance Method Summary collapse
-
#initialize(phones, text) ⇒ Message
constructor
A new instance of Message.
- #to_hash ⇒ Object (also: #to_h)
- #valid? ⇒ Boolean
Constructor Details
#initialize(phones, text) ⇒ Message
Returns a new instance of Message.
8 9 10 11 |
# File 'lib/ileti_merkezi/message.rb', line 8 def initialize(phones, text) @phones = Array(phones) @text = text.to_s end |
Instance Attribute Details
#phones ⇒ Object (readonly)
Returns the value of attribute phones.
6 7 8 |
# File 'lib/ileti_merkezi/message.rb', line 6 def phones @phones end |
#text ⇒ Object (readonly)
Returns the value of attribute text.
6 7 8 |
# File 'lib/ileti_merkezi/message.rb', line 6 def text @text end |
Instance Method Details
#to_hash ⇒ Object Also known as: to_h
13 14 15 16 17 18 19 20 |
# File 'lib/ileti_merkezi/message.rb', line 13 def to_hash raise InvalidMessageError, inspect unless valid? { text: text, receipents: { number: phones } } end |
#valid? ⇒ Boolean
24 25 26 |
# File 'lib/ileti_merkezi/message.rb', line 24 def valid? phones.any? && !text.empty? end |