Class: EhbrsRubyUtils::Bga::WhatsappFormatter::Option

Inherits:
Object
  • Object
show all
Defined in:
lib/ehbrs_ruby_utils/bga/whatsapp_formatter/option.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.assert(obj) ⇒ EhbrsRubyUtils::Bga::WhatsappFormatter::Option

Parameters:

  • obj (Object)

Returns:

Raises:

  • (::ArgumentError)


12
13
14
15
16
17
18
19
# File 'lib/ehbrs_ruby_utils/bga/whatsapp_formatter/option.rb', line 12

def assert(obj)
  return obj if obj.is_a?(self)
  return new(obj.label, obj.value) if obj.respond_to?(:label) && obj.respond_to?(:value)
  return new(obj.fetch(:label), obj.fetch(:value)) if obj.is_a?(::Hash)
  return new(*obj) if obj.is_a?(::Enumerable)

  raise(::ArgumentError, "\"#{obj}\" não pôde ser convertido para #{self}")
end

Instance Method Details

#to_sString

Returns:

  • (String)


25
26
27
# File 'lib/ehbrs_ruby_utils/bga/whatsapp_formatter/option.rb', line 25

def to_s
  "*#{label}:* #{value}"
end