Class: KPI::Entry

Inherits:
Object
  • Object
show all
Defined in:
app/models/kpi/entry.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ Entry

Returns a new instance of Entry.

Raises:

  • (ArgumentError)


4
5
6
7
8
9
10
11
# File 'app/models/kpi/entry.rb', line 4

def initialize(*args)
  options = args.extract_options!
  raise ArgumentError, "Wrong number of arguments (#{args.count} of 2)" unless args.count == 2
  @name, @value = args
  @description = options[:description]
  @important = options[:important] || false
  @unit = options[:unit]
end

Instance Attribute Details

#descriptionObject (readonly)

Returns the value of attribute description.



3
4
5
# File 'app/models/kpi/entry.rb', line 3

def description
  @description
end

#importantObject (readonly)

Returns the value of attribute important.



3
4
5
# File 'app/models/kpi/entry.rb', line 3

def important
  @important
end

#nameObject (readonly)

Returns the value of attribute name.



3
4
5
# File 'app/models/kpi/entry.rb', line 3

def name
  @name
end

#unitObject (readonly)

Returns the value of attribute unit.



3
4
5
# File 'app/models/kpi/entry.rb', line 3

def unit
  @unit
end

#valueObject (readonly)

Returns the value of attribute value.



3
4
5
# File 'app/models/kpi/entry.rb', line 3

def value
  @value
end

Instance Method Details

#important?Boolean

Returns:

  • (Boolean)


13
14
15
# File 'app/models/kpi/entry.rb', line 13

def important?
  !!self.important
end

#to_aObject



17
18
19
# File 'app/models/kpi/entry.rb', line 17

def to_a
  [@title, @value, @description, @unit].compact
end