Class: Rulix::Mutators::Truncate
- Inherits:
-
Object
- Object
- Rulix::Mutators::Truncate
- Defined in:
- lib/rulix/mutators/truncate.rb
Instance Attribute Summary collapse
-
#length ⇒ Object
Returns the value of attribute length.
Instance Method Summary collapse
- #call(string) ⇒ Object
-
#initialize(length) ⇒ Truncate
constructor
A new instance of Truncate.
- #to_proc ⇒ Object
Constructor Details
#initialize(length) ⇒ Truncate
Returns a new instance of Truncate.
6 7 8 |
# File 'lib/rulix/mutators/truncate.rb', line 6 def initialize length self.length = length end |
Instance Attribute Details
#length ⇒ Object
Returns the value of attribute length.
4 5 6 |
# File 'lib/rulix/mutators/truncate.rb', line 4 def length @length end |
Instance Method Details
#call(string) ⇒ Object
14 15 16 17 18 |
# File 'lib/rulix/mutators/truncate.rb', line 14 def call string raise ArgumentError, "argument is not a string" unless string.is_a? String string.slice(0, length) end |
#to_proc ⇒ Object
10 11 12 |
# File 'lib/rulix/mutators/truncate.rb', line 10 def to_proc method(:call) end |