Class: TextParts

Inherits:
Object
  • Object
show all
Defined in:
lib/numerals/format/text_parts.rb

Overview

Numeral parts represented in text form

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(numeral = nil) ⇒ TextParts

Returns a new instance of TextParts



17
18
19
20
21
22
23
# File 'lib/numerals/format/text_parts.rb', line 17

def initialize(numeral = nil)
  @numeral = numeral
  @special = nil
  @sign = @integer = @fractional = @repeat = @exponent = @exponent_base = nil
  @integer_value = @exponent_value = @exponent_base_value = nil
  @detect_repeat = false
end

Instance Attribute Details

#detect_repeatObject

Returns the value of attribute detect_repeat



28
29
30
# File 'lib/numerals/format/text_parts.rb', line 28

def detect_repeat
  @detect_repeat
end

#exponent_base_valueObject

Returns the value of attribute exponent_base_value



28
29
30
# File 'lib/numerals/format/text_parts.rb', line 28

def exponent_base_value
  @exponent_base_value
end

#exponent_valueObject

Returns the value of attribute exponent_value



28
29
30
# File 'lib/numerals/format/text_parts.rb', line 28

def exponent_value
  @exponent_value
end

#integer_valueObject

Returns the value of attribute integer_value



28
29
30
# File 'lib/numerals/format/text_parts.rb', line 28

def integer_value
  @integer_value
end

#numeralObject (readonly)

Returns the value of attribute numeral



29
30
31
# File 'lib/numerals/format/text_parts.rb', line 29

def numeral
  @numeral
end

Class Method Details

.text_part(*names) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
# File 'lib/numerals/format/text_parts.rb', line 5

def self.text_part(*names)
  names.each do |name|
    attr_writer name.to_sym
    define_method name do
      instance_variable_get("@#{name}") || ""
    end
    define_method :"#{name}?" do
      !send(name.to_sym).empty?
    end
  end
end

Instance Method Details

#detect_repeat?Boolean

Returns:

  • (Boolean)


31
32
33
# File 'lib/numerals/format/text_parts.rb', line 31

def detect_repeat?
  @detect_repeat
end