Module: VV::IntegerMethods
- Included in:
- Integer
- Defined in:
- lib/vv/integer_methods.rb
Defined Under Namespace
Modules: ClassMethods
Class Method Summary collapse
Instance Method Summary collapse
- #characters(character, fail_on_negative: false) ⇒ Object
- #dashes ⇒ Object
- #spaces ⇒ Object
- #to_i! ⇒ Object
Class Method Details
.included(base) ⇒ Object
4 5 6 |
# File 'lib/vv/integer_methods.rb', line 4 def self.included(base) base.extend(ClassMethods) end |
Instance Method Details
#characters(character, fail_on_negative: false) ⇒ Object
24 25 26 27 28 29 30 31 32 |
# File 'lib/vv/integer_methods.rb', line 24 def characters character, fail_on_negative: false = "Expected single character, not #{character}." fail ArgumentError, if character.length > 1 = "Expected non-negative integer, not `#{self}`." fail if self < 0 and fail_on_negative ( self > 0 ) ? ( character * self ) : String.empty_string end |
#dashes ⇒ Object
20 21 22 |
# File 'lib/vv/integer_methods.rb', line 20 def dashes characters String.dash end |
#spaces ⇒ Object
16 17 18 |
# File 'lib/vv/integer_methods.rb', line 16 def spaces characters String.space end |
#to_i! ⇒ Object
34 35 36 |
# File 'lib/vv/integer_methods.rb', line 34 def to_i! self end |