Class: Charosc::Text

Inherits:
Object
  • Object
show all
Defined in:
lib/charosc/text.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(str) ⇒ Text

str - String input



6
7
8
# File 'lib/charosc/text.rb', line 6

def initialize(str)
  @str = str
end

Instance Attribute Details

#strObject (readonly)

Returns the value of attribute str.



3
4
5
# File 'lib/charosc/text.rb', line 3

def str
  @str
end

Instance Method Details

#charsObject



10
11
12
# File 'lib/charosc/text.rb', line 10

def chars
  @chars ||= str.scan(/./)
end

#wordsObject



14
15
16
# File 'lib/charosc/text.rb', line 14

def words
  @words ||= str.split(/\s+/)
end