Class: Buildmeister::Bin

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/buildmeister/bin.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(lighthouse_bin, mode = :verbose, options = {}) ⇒ Bin

Returns a new instance of Bin.



12
13
14
15
16
17
18
# File 'lib/buildmeister/bin.rb', line 12

def initialize(lighthouse_bin, mode = :verbose, options = {})
  self.bin  = lighthouse_bin
  self.mode = mode
  self.annotations = options[:annotations] || {}
  
  refresh!
end

Instance Attribute Details

#annotationsObject

Returns the value of attribute annotations.



6
7
8
# File 'lib/buildmeister/bin.rb', line 6

def annotations
  @annotations
end

#binObject

Returns the value of attribute bin.



6
7
8
# File 'lib/buildmeister/bin.rb', line 6

def bin
  @bin
end

#last_valueObject

Returns the value of attribute last_value.



6
7
8
# File 'lib/buildmeister/bin.rb', line 6

def last_value
  @last_value
end

#modeObject

Returns the value of attribute mode.



6
7
8
# File 'lib/buildmeister/bin.rb', line 6

def mode
  @mode
end

#valueObject

Returns the value of attribute value.



6
7
8
# File 'lib/buildmeister/bin.rb', line 6

def value
  @value
end

Instance Method Details

#changed?Boolean

Returns:

  • (Boolean)


41
42
43
# File 'lib/buildmeister/bin.rb', line 41

def changed?
  value != last_value
end

#displayObject



37
38
39
# File 'lib/buildmeister/bin.rb', line 37

def display
  "#{name}: #{value}"
end

#refresh!Object



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/buildmeister/bin.rb', line 20

def refresh!
  self.last_value = value
  
  case mode
  when :verbose
    self.value = bin.tickets.map do |tkt|
      str = "#{tkt.id}"
      annotations.each do |tag_name, identifier|
        str << identifier if tkt.tags.include?(tag_name)
      end
      str
    end.join(', ')
  when :quiet
    self.value = bin.tickets_count
  end
end