Class: GreekABC::Letter
- Inherits:
-
Object
- Object
- GreekABC::Letter
- Defined in:
- lib/greek_abc/letter.rb
Overview
Represents a letter object
Instance Attribute Summary collapse
-
#lower ⇒ String
readonly
Lowercase representation.
-
#lower_alt ⇒ String?
readonly
Lowercase alternative represenation, if exists.
-
#name ⇒ String
readonly
Letter name.
-
#position ⇒ Integer
readonly
Letter position in the alphabet.
-
#upper ⇒ String
readonly
Uppercase representation.
Instance Method Summary collapse
-
#initialize(position:, name:, lower:, upper:, lower_alt: nil) ⇒ Letter
constructor
Initialize a new letter.
-
#to_s ⇒ String
String representation of a Letter object.
Constructor Details
#initialize(position:, name:, lower:, upper:, lower_alt: nil) ⇒ Letter
Initialize a new letter
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
#lower ⇒ String (readonly)
Returns 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_alt ⇒ String? (readonly)
Returns 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 |
#name ⇒ String (readonly)
Returns 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 |
#position ⇒ Integer (readonly)
Returns 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 |
#upper ⇒ String (readonly)
Returns 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_s ⇒ String
String representation of a GreekABC::Letter object
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 |