Class: GreekABC::Letter

Inherits:
Object
  • Object
show all
Defined in:
lib/greek_abc/letter.rb

Overview

Represents a letter object

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(position:, name:, lower:, upper:, lower_alt: nil) ⇒ Letter

Initialize a new letter

Parameters:

  • position (Integer)

    (see #position)

  • name (String)

    (see #name)

  • lower (String)

    (see #lower)

  • upper (String)

    (see #upper)

  • lower_alt (String, nil) (defaults to: nil)

    (see #lower_alt)



29
30
31
32
33
34
35
# File 'lib/greek_abc/letter.rb', line 29

def initialize(position:, name:, lower:, upper:, lower_alt: nil)
  @position = position
  @name = name
  @lower = lower
  @lower_alt = lower_alt
  @upper = upper
end

Instance Attribute Details

#lowerString (readonly)

Returns lowercase representation.

Returns:

  • (String)

    lowercase representation



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/greek_abc/letter.rb', line 17

class Letter
  attr_reader :position, :name, :lower, :lower_alt, :upper

  # Initialize a new letter
  #
  # @param [Integer] position (see {position})
  # @param [String] name (see {name})
  # @param [String] lower (see {lower})
  # @param [String] upper (see {upper})
  # @param [String, nil] lower_alt (see {lower_alt})
  # @return [Letter]
  #
  def initialize(position:, name:, lower:, upper:, lower_alt: nil)
    @position = position
    @name = name
    @lower = lower
    @lower_alt = lower_alt
    @upper = upper
  end

  #
  # String representation of a {Letter} object
  # @return [String]
  def to_s
    lower_alt = " / #{@lower_alt}" if @lower_alt

    "Letter ##{@position} '#{@name}', lowercase '#{@lower}" \
    "#{lower_alt}', uppercase '#{@upper}'"
  end
end

#lower_altString? (readonly)

Returns lowercase alternative represenation, if exists.

Returns:

  • (String, nil)

    lowercase alternative represenation, if exists



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/greek_abc/letter.rb', line 17

class Letter
  attr_reader :position, :name, :lower, :lower_alt, :upper

  # Initialize a new letter
  #
  # @param [Integer] position (see {position})
  # @param [String] name (see {name})
  # @param [String] lower (see {lower})
  # @param [String] upper (see {upper})
  # @param [String, nil] lower_alt (see {lower_alt})
  # @return [Letter]
  #
  def initialize(position:, name:, lower:, upper:, lower_alt: nil)
    @position = position
    @name = name
    @lower = lower
    @lower_alt = lower_alt
    @upper = upper
  end

  #
  # String representation of a {Letter} object
  # @return [String]
  def to_s
    lower_alt = " / #{@lower_alt}" if @lower_alt

    "Letter ##{@position} '#{@name}', lowercase '#{@lower}" \
    "#{lower_alt}', uppercase '#{@upper}'"
  end
end

#nameString (readonly)

Returns letter name.

Returns:

  • (String)

    letter name



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/greek_abc/letter.rb', line 17

class Letter
  attr_reader :position, :name, :lower, :lower_alt, :upper

  # Initialize a new letter
  #
  # @param [Integer] position (see {position})
  # @param [String] name (see {name})
  # @param [String] lower (see {lower})
  # @param [String] upper (see {upper})
  # @param [String, nil] lower_alt (see {lower_alt})
  # @return [Letter]
  #
  def initialize(position:, name:, lower:, upper:, lower_alt: nil)
    @position = position
    @name = name
    @lower = lower
    @lower_alt = lower_alt
    @upper = upper
  end

  #
  # String representation of a {Letter} object
  # @return [String]
  def to_s
    lower_alt = " / #{@lower_alt}" if @lower_alt

    "Letter ##{@position} '#{@name}', lowercase '#{@lower}" \
    "#{lower_alt}', uppercase '#{@upper}'"
  end
end

#positionInteger (readonly)

Returns letter position in the alphabet.

Returns:

  • (Integer)

    letter position in the alphabet



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/greek_abc/letter.rb', line 17

class Letter
  attr_reader :position, :name, :lower, :lower_alt, :upper

  # Initialize a new letter
  #
  # @param [Integer] position (see {position})
  # @param [String] name (see {name})
  # @param [String] lower (see {lower})
  # @param [String] upper (see {upper})
  # @param [String, nil] lower_alt (see {lower_alt})
  # @return [Letter]
  #
  def initialize(position:, name:, lower:, upper:, lower_alt: nil)
    @position = position
    @name = name
    @lower = lower
    @lower_alt = lower_alt
    @upper = upper
  end

  #
  # String representation of a {Letter} object
  # @return [String]
  def to_s
    lower_alt = " / #{@lower_alt}" if @lower_alt

    "Letter ##{@position} '#{@name}', lowercase '#{@lower}" \
    "#{lower_alt}', uppercase '#{@upper}'"
  end
end

#upperString (readonly)

Returns uppercase representation.

Returns:

  • (String)

    uppercase representation



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/greek_abc/letter.rb', line 17

class Letter
  attr_reader :position, :name, :lower, :lower_alt, :upper

  # Initialize a new letter
  #
  # @param [Integer] position (see {position})
  # @param [String] name (see {name})
  # @param [String] lower (see {lower})
  # @param [String] upper (see {upper})
  # @param [String, nil] lower_alt (see {lower_alt})
  # @return [Letter]
  #
  def initialize(position:, name:, lower:, upper:, lower_alt: nil)
    @position = position
    @name = name
    @lower = lower
    @lower_alt = lower_alt
    @upper = upper
  end

  #
  # String representation of a {Letter} object
  # @return [String]
  def to_s
    lower_alt = " / #{@lower_alt}" if @lower_alt

    "Letter ##{@position} '#{@name}', lowercase '#{@lower}" \
    "#{lower_alt}', uppercase '#{@upper}'"
  end
end

Instance Method Details

#to_sString

String representation of a GreekABC::Letter object

Returns:

  • (String)


40
41
42
43
44
45
# File 'lib/greek_abc/letter.rb', line 40

def to_s
  lower_alt = " / #{@lower_alt}" if @lower_alt

  "Letter ##{@position} '#{@name}', lowercase '#{@lower}" \
  "#{lower_alt}', uppercase '#{@upper}'"
end