Class: HG::Finance::Stock

Inherits:
Object
  • Object
show all
Defined in:
lib/hg/finance/stock.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Stock

Returns a new instance of Stock.



19
20
21
22
23
24
25
26
# File 'lib/hg/finance/stock.rb', line 19

def initialize(options = {})
  if options.count != 0
    @name      = options[:name] if options[:name]
    # @mic       = options[:mic] if options[:mic]
    @location  = options[:location] if options[:location]
    @variation = options[:variation] if options[:variation]
  end
end

Instance Attribute Details

#locationObject

Public: Location



14
15
16
# File 'lib/hg/finance/stock.rb', line 14

def location
  @location
end

#nameObject

Public: Name



8
9
10
# File 'lib/hg/finance/stock.rb', line 8

def name
  @name
end

#variationObject

Public: Last util day variation



17
18
19
# File 'lib/hg/finance/stock.rb', line 17

def variation
  @variation
end

Instance Method Details

#inspectObject



37
38
39
# File 'lib/hg/finance/stock.rb', line 37

def inspect
  self.to_s
end

#to_s(separator = ' - ') ⇒ Object



28
29
30
31
32
33
34
35
# File 'lib/hg/finance/stock.rb', line 28

def to_s separator = ' - '
  to_return = []

  to_return << "#{self.name} - #{self.location}" if self.name && self.location
  to_return << "#{Locale.get_format(:variation).to_s.capitalize}: " + self.variation.to_s if self.variation

  return to_return.join(separator)
end