Sha256: 88491dadb52c47d0bb3ee459116195af63f67c457df86f154a4126c79aa99679

Contents?: true

Size: 853 Bytes

Versions: 8

Compression:

Stored size: 853 Bytes

Contents

# frozen_string_literal: true

require 'eac_ruby_utils/core_ext'

module EhbrsRubyUtils
  module Bga
    module WhatsappFormatter
      class Option
        class << self
          # @param obj [Object]
          # @return [EhbrsRubyUtils::Bga::WhatsappFormatter::Option]
          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
        end

        common_constructor :label, :value

        # @return [String]
        def to_s
          "*#{label}:* #{value}"
        end
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
ehbrs_ruby_utils-0.44.3 lib/ehbrs_ruby_utils/bga/whatsapp_formatter/option.rb
ehbrs_ruby_utils-0.44.2 lib/ehbrs_ruby_utils/bga/whatsapp_formatter/option.rb
ehbrs_ruby_utils-0.44.1 lib/ehbrs_ruby_utils/bga/whatsapp_formatter/option.rb
ehbrs_ruby_utils-0.44.0 lib/ehbrs_ruby_utils/bga/whatsapp_formatter/option.rb
ehbrs_ruby_utils-0.41.1 lib/ehbrs_ruby_utils/bga/whatsapp_formatter/option.rb
ehbrs_ruby_utils-0.41.0 lib/ehbrs_ruby_utils/bga/whatsapp_formatter/option.rb
ehbrs_ruby_utils-0.40.0 lib/ehbrs_ruby_utils/bga/whatsapp_formatter/option.rb
ehbrs_ruby_utils-0.39.0 lib/ehbrs_ruby_utils/bga/whatsapp_formatter/option.rb