Class: Economic::Entity::Handle

Inherits:
Object
  • Object
show all
Defined in:
lib/economic/entity.rb

Instance Attribute Summary (collapse)

Instance Method Summary (collapse)

Constructor Details

- (Handle) initialize(hash)

Returns a new instance of Handle



6
7
8
9
# File 'lib/economic/entity.rb', line 6

def initialize(hash)
  @id = hash[:id]
  @number = hash[:number]
end

Instance Attribute Details

- (Object) id

Returns the value of attribute id



4
5
6
# File 'lib/economic/entity.rb', line 4

def id
  @id
end

- (Object) number

Returns the value of attribute number



4
5
6
# File 'lib/economic/entity.rb', line 4

def number
  @number
end

Instance Method Details

- (Object) ==(other)



22
23
24
25
26
# File 'lib/economic/entity.rb', line 22

def ==(other)
  return false if other.nil?
  return false unless other.respond_to?(:id) && other.respond_to?(:number)
  self.id == other.id && self.number == other.number
end

- (Object) [](key)



18
19
20
# File 'lib/economic/entity.rb', line 18

def [](key)
  {:id => @id, :number => @number}[key]
end

- (Object) to_hash



11
12
13
14
15
16
# File 'lib/economic/entity.rb', line 11

def to_hash
  hash = {}
  hash['Id'] = id unless id.blank?
  hash['Number'] = number unless number.blank?
  hash
end