Class: Calendario::RenderedMonth

Inherits:
Object
  • Object
show all
Defined in:
lib/calendario/rendered_month.rb

Overview

A cal-like representation of a month:

January

Su Mo Tu We Th Fr Sa

         1  2  3  4
5  6  7  8  9 10 11

12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(lines) ⇒ RenderedMonth

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Initializes a rendered month

initials and 4 to 5 lines of weeks

Parameters:

  • lines (Array<String>)

    List of lines representing a month. The month name, the weekday



26
27
28
# File 'lib/calendario/rendered_month.rb', line 26

def initialize(lines)
  @lines = lines
end

Instance Attribute Details

#linesArray<String> (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

A list of lines representing a month. The month name, the weekday initials and 4 to 5 lines of weeks

Returns:

  • (Array<String>)


18
19
20
# File 'lib/calendario/rendered_month.rb', line 18

def lines
  @lines
end

Instance Method Details

#[](index) ⇒ Array<String>

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Finds one or more lines of the rendered month

Returns:

  • (Array<String>)


71
72
73
# File 'lib/calendario/rendered_month.rb', line 71

def [](index)
  lines.public_send(:[], index)
end

#nameString

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

The centered name of the month

Returns:

  • (String)


44
45
46
# File 'lib/calendario/rendered_month.rb', line 44

def name
  lines[0]
end

#to_sString

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns the textual representation of a month

Returns:

  • (String)


35
36
37
# File 'lib/calendario/rendered_month.rb', line 35

def to_s
  lines.join("\n")
end

#weekdaysString

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

The list of weekday initials (Su Mo Tu We Th Fr Sa)

Returns:

  • (String)


53
54
55
# File 'lib/calendario/rendered_month.rb', line 53

def weekdays
  lines[1]
end

#weeksArray<String>

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns 4 or 5 rows of weeks

Returns:

  • (Array<String>)


62
63
64
# File 'lib/calendario/rendered_month.rb', line 62

def weeks
  lines[2..-1]
end