Sha256: 6e60d28209c56b25cb4e4592219dc82d69a0c1fd62b23bb17d976bff56c0b0ec

Contents?: true

Size: 856 Bytes

Versions: 23

Compression:

Stored size: 856 Bytes

Contents

class Gillbus
  class TicketsOption
    extend Fields
    include UpdateAttrs

    # идентификатор опции
    field :id, :int, key: 'ID'

    # текст опции
    field :text, :string, key: :__content__

    def self.parse(doc, instance: nil, parent: nil, options: {})
      instance = new
      if doc.is_a?(String)
        instance.text = doc
      elsif doc.is_a?(Array)
        raise ArgumentError, "Unable to parse TicketsOption: #{doc.inspect}" unless doc.size == 2
        instance.id = doc.first.fetch('ID').to_i
        instance.text = doc.last
      elsif doc.is_a?(Hash) #legacy data made with MultiXML
        instance.id = doc.fetch('ID')
        instance.text = doc.fetch('__content__')
      else
        raise ArgumentError, "Unable to parse TicketsOption: #{doc.inspect}"
      end
      instance
    end
  end
end

Version data entries

23 entries across 23 versions & 1 rubygems

Version Path
gillbus-0.23.0 lib/gillbus/structs/tickets_option.rb
gillbus-0.22.9 lib/gillbus/structs/tickets_option.rb
gillbus-0.22.8 lib/gillbus/structs/tickets_option.rb
gillbus-0.22.7 lib/gillbus/structs/tickets_option.rb
gillbus-0.22.6 lib/gillbus/structs/tickets_option.rb
gillbus-0.22.5 lib/gillbus/structs/tickets_option.rb
gillbus-0.22.4 lib/gillbus/structs/tickets_option.rb
gillbus-0.22.3 lib/gillbus/structs/tickets_option.rb
gillbus-0.22.2 lib/gillbus/structs/tickets_option.rb
gillbus-0.22.1 lib/gillbus/structs/tickets_option.rb
gillbus-0.22.0 lib/gillbus/structs/tickets_option.rb
gillbus-0.21.0 lib/gillbus/structs/tickets_option.rb
gillbus-0.20.9 lib/gillbus/structs/tickets_option.rb
gillbus-0.20.8 lib/gillbus/structs/tickets_option.rb
gillbus-0.20.7 lib/gillbus/structs/tickets_option.rb
gillbus-0.20.6 lib/gillbus/structs/tickets_option.rb
gillbus-0.20.5 lib/gillbus/structs/tickets_option.rb
gillbus-0.20.4 lib/gillbus/structs/tickets_option.rb
gillbus-0.20.3 lib/gillbus/structs/tickets_option.rb
gillbus-0.20.2 lib/gillbus/structs/tickets_option.rb