Class: Unit::Types::Phone
- Inherits:
-
Object
- Object
- Unit::Types::Phone
- Defined in:
- lib/unit-ruby/types/phone.rb
Instance Attribute Summary collapse
-
#country_code ⇒ Object
readonly
Returns the value of attribute country_code.
-
#number ⇒ Object
readonly
Returns the value of attribute number.
Class Method Summary collapse
Instance Method Summary collapse
- #as_json_api ⇒ Object
-
#initialize(country_code:, number:) ⇒ Phone
constructor
A new instance of Phone.
Constructor Details
#initialize(country_code:, number:) ⇒ Phone
Returns a new instance of Phone.
6 7 8 9 |
# File 'lib/unit-ruby/types/phone.rb', line 6 def initialize(country_code:, number:) @country_code = country_code @number = number end |
Instance Attribute Details
#country_code ⇒ Object (readonly)
Returns the value of attribute country_code.
4 5 6 |
# File 'lib/unit-ruby/types/phone.rb', line 4 def country_code @country_code end |
#number ⇒ Object (readonly)
Returns the value of attribute number.
4 5 6 |
# File 'lib/unit-ruby/types/phone.rb', line 4 def number @number end |
Class Method Details
.cast(val) ⇒ Object
11 12 13 14 15 16 |
# File 'lib/unit-ruby/types/phone.rb', line 11 def self.cast(val) return val if val.is_a? self return nil if val.nil? new(country_code: val[:country_code], number: val[:number]) end |
Instance Method Details
#as_json_api ⇒ Object
18 19 20 |
# File 'lib/unit-ruby/types/phone.rb', line 18 def as_json_api { country_code: country_code, number: number } end |