Class: ViewHistory

Inherits:
Struct
  • Object
show all
Defined in:
lib/commands/view_history.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#date_formatObject

Returns the value of attribute date_format

Returns:

  • (Object)

    the current value of date_format



1
2
3
# File 'lib/commands/view_history.rb', line 1

def date_format
  @date_format
end

#project_nameObject

Returns the value of attribute project_name

Returns:

  • (Object)

    the current value of project_name



1
2
3
# File 'lib/commands/view_history.rb', line 1

def project_name
  @project_name
end

#properties(project = project) ⇒ Object

Returns the value of attribute properties

Returns:

  • (Object)

    the current value of properties



1
2
3
# File 'lib/commands/view_history.rb', line 1

def properties
  @properties
end

Instance Method Details

#call(formatter = formatter, records = records) ⇒ Object



2
3
4
# File 'lib/commands/view_history.rb', line 2

def call formatter = formatter, records = records
  formatter.present records
end

#format(date_format = date_format, metrics = metrics) ⇒ Object



28
29
30
# File 'lib/commands/view_history.rb', line 28

def format date_format = date_format, metrics = metrics
  {'Date' => "created_at.strftime('#{date_format}')"}.merge list_metrics_format(metrics)
end

#formatter(format = format) ⇒ Object



14
15
16
# File 'lib/commands/view_history.rb', line 14

def formatter format = format
  ConsoleFormatter.new format
end

#metrics(project = project, properties = properties) ⇒ Object



22
23
24
25
26
# File 'lib/commands/view_history.rb', line 22

def metrics project = project, properties = properties
  properties.map do |property|
    project.property property
  end.compact
end

#project(project_name = project_name) ⇒ Object



6
7
8
# File 'lib/commands/view_history.rb', line 6

def project project_name = project_name
  Project.find_by name: project_name
end

#records(metrics = metrics) ⇒ Object



10
11
12
# File 'lib/commands/view_history.rb', line 10

def records metrics = metrics
  metrics.collect(&:values).flatten
end