Class: Realize::Format::Split
- Inherits:
-
Object
- Object
- Realize::Format::Split
- Defined in:
- lib/realize/format/split.rb
Overview
Take a string value and split it on the specified ‘by’ value. By default, it will be split on a blank space. For example: ‘123 456 789’ would yield [‘123’, ‘456’, ‘789’]. If the value is not a string then it will be converted to a string by calling #to_s on it.
Constant Summary collapse
- DEFAULT_BY =
' '
Instance Attribute Summary collapse
-
#by ⇒ Object
readonly
Returns the value of attribute by.
Instance Method Summary collapse
-
#initialize(by: DEFAULT_BY) ⇒ Split
constructor
A new instance of Split.
- #transform(_resolver, value, _time, _record) ⇒ Object
Constructor Details
#initialize(by: DEFAULT_BY) ⇒ Split
Returns a new instance of Split.
22 23 24 25 26 |
# File 'lib/realize/format/split.rb', line 22 def initialize(by: DEFAULT_BY) @by = by.to_s freeze end |
Instance Attribute Details
#by ⇒ Object (readonly)
Returns the value of attribute by.
20 21 22 |
# File 'lib/realize/format/split.rb', line 20 def by @by end |
Instance Method Details
#transform(_resolver, value, _time, _record) ⇒ Object
28 29 30 |
# File 'lib/realize/format/split.rb', line 28 def transform(_resolver, value, _time, _record) value.to_s.split(by) end |