Class: TheCity::Barcode

Inherits:
ApiObject show all
Defined in:
lib/api/barcode.rb

Instance Attribute Summary

Attributes inherited from ApiObject

#error_messages, #marked_for_destruction

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from ApiObject

__tc_attributes, #initialize_from_json_object, #is_deleted?, #set_attributes, tc_attr_accessor, #to_attributes

Constructor Details

#initialize(json_data = nil) ⇒ Barcode

Constructor.

Parameters:

  • json_data (optional) (defaults to: nil)

    JSON data of the barcode.



27
28
29
# File 'lib/api/barcode.rb', line 27

def initialize(json_data = nil)
  initialize_from_json_object(json_data) unless json_data.nil?
end

Class Method Details

.load_by_id(barcode_id) ⇒ Object

Loads the barocde by the specified ID.

Returns a new TheCity::Barcode object.

Parameters:

  • barcode_id

    The ID of the barcode to load.



16
17
18
19
20
21
# File 'lib/api/barcode.rb', line 16

def self.load_by_id(barcode_id)
  reader = BarcodeReader.new(barcode_id)
  self.new(reader.load_feed)
rescue
  nil
end

Instance Method Details

#deleteObject



35
36
37
# File 'lib/api/barcode.rb', line 35

def delete
  raise 'Barcode does not have a delete method'
end

#saveObject



31
32
33
# File 'lib/api/barcode.rb', line 31

def save
  raise 'Barcode does not have a save method'
end