Class: Mess::Plotter

Inherits:
Object
  • Object
show all
Defined in:
lib/mess/plotter.rb

Direct Known Subclasses

DailyMsgs, TotalMsgs, WordFrequency, WordsPerMessage

Constant Summary collapse

@@available =

stores all available plotters

Hash.new

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(chat) ⇒ Plotter

Returns a new instance of Plotter.



30
31
32
# File 'lib/mess/plotter.rb', line 30

def initialize chat
  @chat = chat
end

Instance Attribute Details

#dataObject (readonly)

Returns the value of attribute data.



20
21
22
# File 'lib/mess/plotter.rb', line 20

def data
  @data
end

Class Method Details

.availableObject

lists all available plotters



16
17
18
# File 'lib/mess/plotter.rb', line 16

def self.available
  @@available
end

.describe(desc) ⇒ Object

needs to be described in order to be “centrally” available adds plotter class to available plotters with custom description name is derived from plotter class name



25
26
27
28
# File 'lib/mess/plotter.rb', line 25

def self.describe desc
  name = self.to_s.match(/Mess::(?<name>\w+)$/)[:name]
  @@available[name] = desc
end

Instance Method Details

#runObject

should return Mess::Plot



35
36
37
38
39
# File 'lib/mess/plotter.rb', line 35

def run
  @chat.msgs.each { |msg| push(msg) }
  finalize
  generate_plot
end