Class: NeedForType::FileManager
- Inherits:
-
Object
- Object
- NeedForType::FileManager
- Defined in:
- lib/need_for_type/file_manager.rb
Instance Attribute Summary collapse
-
#text ⇒ Object
Returns the value of attribute text.
-
#text_id ⇒ Object
Returns the value of attribute text_id.
Instance Method Summary collapse
-
#initialize ⇒ FileManager
constructor
A new instance of FileManager.
- #read_random_text ⇒ Object
Constructor Details
#initialize ⇒ FileManager
Returns a new instance of FileManager.
5 6 7 |
# File 'lib/need_for_type/file_manager.rb', line 5 def initialize() @path = "#{NeedForType::GEM_ROOT}/assets/texts/" end |
Instance Attribute Details
#text ⇒ Object
Returns the value of attribute text.
3 4 5 |
# File 'lib/need_for_type/file_manager.rb', line 3 def text @text end |
#text_id ⇒ Object
Returns the value of attribute text_id.
3 4 5 |
# File 'lib/need_for_type/file_manager.rb', line 3 def text_id @text_id end |
Instance Method Details
#read_random_text ⇒ Object
9 10 11 12 13 |
# File 'lib/need_for_type/file_manager.rb', line 9 def read_random_text directory_count = Dir[File.join(@path, '**', '*')].count @text_id = rand(1..directory_count) @text = File.read("#{@path}/text-#{@text_id}.txt").strip end |