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

#initialize(hash) ⇒ 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

#idObject

Returns the value of attribute id



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

def id
  @id
end

#numberObject

Returns the value of attribute number



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

def number
  @number
end

Instance Method Details

#==(other) ⇒ Object



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

#[](key) ⇒ Object



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

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

#to_hashObject



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