Class: GemDating::Result

Inherits:
Object
  • Object
show all
Defined in:
lib/gem_dating/result.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(specs) ⇒ Result

Returns a new instance of Result.



6
7
8
# File 'lib/gem_dating/result.rb', line 6

def initialize(specs)
  @specs = specs
end

Instance Attribute Details

#specsObject (readonly)

Returns the value of attribute specs.



5
6
7
# File 'lib/gem_dating/result.rb', line 5

def specs
  @specs
end

Instance Method Details

#table_printObject



24
25
26
# File 'lib/gem_dating/result.rb', line 24

def table_print
  TablePrint::Printer.table_print(specs, [:name, :version, {date: {time_format: "%Y-%m-%d", width: 10}}]).encode("utf-8")
end

#to_aObject



10
11
12
# File 'lib/gem_dating/result.rb', line 10

def to_a
  specs
end

#to_hObject



14
15
16
17
18
19
20
21
22
# File 'lib/gem_dating/result.rb', line 14

def to_h
  specs.each_with_object({}) do |spec, result|
    result[spec.name] = {
      "name" => spec.name,
      "version" => spec.version.to_s,
      "date" => spec.date.strftime("%Y-%m-%d")
    }
  end
end