Class: Pueri::Vax

Inherits:
Object
  • Object
show all
Defined in:
lib/pueri/vax.rb

Overview

Gets input from child vaccination calendar for children (PNI) and an age in days. With this, process which vaccines are due by that age.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(norm_age) ⇒ Vax

Returns a new instance of Vax.



10
11
12
13
14
# File 'lib/pueri/vax.rb', line 10

def initialize(norm_age)
  init_base
  @range = calc_range(norm_age)
  parse_calendar
end

Instance Attribute Details

#calendarObject (readonly)

Returns the value of attribute calendar.



7
8
9
# File 'lib/pueri/vax.rb', line 7

def calendar
  @calendar
end

#headerObject (readonly)

Returns the value of attribute header.



7
8
9
# File 'lib/pueri/vax.rb', line 7

def header
  @header
end

#notesObject (readonly)

Returns the value of attribute notes.



7
8
9
# File 'lib/pueri/vax.rb', line 7

def notes
  @notes
end

#rangeObject (readonly)

Returns the value of attribute range.



8
9
10
# File 'lib/pueri/vax.rb', line 8

def range
  @range
end

#tableObject (readonly)

Returns the value of attribute table.



8
9
10
# File 'lib/pueri/vax.rb', line 8

def table
  @table
end

Instance Method Details

#parse_notesString

Retrieves the notes for the vaccination calendar, prettified.

Returns:

  • (String)

    The notes for the vaccines’ calendar.



19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/pueri/vax.rb', line 19

def parse_notes
  r = ''
  max = @notes.size
  p = Pastel.new

  @notes.each_with_index do |line, k|
    pre = ' ' * (max - (k + 1))
    pre += '*' * (k.to_i + 1)
    r += "\n#{p.cyan(pre)} #{line}"
  end

  r
end