Class: Sep::Separator
- Inherits:
-
Object
- Object
- Sep::Separator
- Defined in:
- lib/sep/separator.rb
Constant Summary collapse
- ANALYSIS =
/([[:punct:]\s]*)(\w+)([[:punct:]]*)(\s*)/
Instance Attribute Summary collapse
-
#text ⇒ Object
readonly
Returns the value of attribute text.
-
#words_data ⇒ Object
readonly
Returns the value of attribute words_data.
Instance Method Summary collapse
-
#initialize(text) ⇒ Separator
constructor
text - String text to separate.
- #leading_space ⇒ Object
- #space ⇒ Object
- #words ⇒ Object
Constructor Details
#initialize(text) ⇒ Separator
text - String text to separate
8 9 10 11 12 |
# File 'lib/sep/separator.rb', line 8 def initialize(text) @text = text analyze end |
Instance Attribute Details
#text ⇒ Object (readonly)
Returns the value of attribute text.
3 4 5 |
# File 'lib/sep/separator.rb', line 3 def text @text end |
#words_data ⇒ Object (readonly)
Returns the value of attribute words_data.
3 4 5 |
# File 'lib/sep/separator.rb', line 3 def words_data @words_data end |
Instance Method Details
#leading_space ⇒ Object
14 15 16 |
# File 'lib/sep/separator.rb', line 14 def leading_space text.match(/(\s*)/).captures[0] end |
#space ⇒ Object
18 19 20 |
# File 'lib/sep/separator.rb', line 18 def space [leading_space] + words_data.map {|wd| wd[:space_post] } end |
#words ⇒ Object
22 23 24 |
# File 'lib/sep/separator.rb', line 22 def words words_data.map {|wd| wd[:word] } end |