Class: Ruco::Editor
Instance Attribute Summary collapse
-
#file ⇒ Object
readonly
Returns the value of attribute file.
Instance Method Summary collapse
- #delete(*args) ⇒ Object
- #find(text) ⇒ Object
-
#initialize(file, options) ⇒ Editor
constructor
A new instance of Editor.
- #insert(text) ⇒ Object
- #modified? ⇒ Boolean
- #reset ⇒ Object
- #save ⇒ Object
Constructor Details
Instance Attribute Details
#file ⇒ Object (readonly)
Returns the value of attribute file.
3 4 5 |
# File 'lib/ruco/editor.rb', line 3 def file @file end |
Instance Method Details
#delete(*args) ⇒ Object
25 26 27 28 |
# File 'lib/ruco/editor.rb', line 25 def delete(*args) text_area.delete(*args) @modified = true end |
#find(text) ⇒ Object
13 14 15 16 |
# File 'lib/ruco/editor.rb', line 13 def find(text) index = text_area.content.index(text, text_area.cursor_index+1) || text_area.cursor_index move :to, *text_area.position_for_index(index) end |
#insert(text) ⇒ Object
20 21 22 23 |
# File 'lib/ruco/editor.rb', line 20 def insert(text) @modified = true text_area.insert(text) end |
#modified? ⇒ Boolean
30 31 32 |
# File 'lib/ruco/editor.rb', line 30 def modified? @modified end |
#reset ⇒ Object
18 |
# File 'lib/ruco/editor.rb', line 18 def reset;end |
#save ⇒ Object
34 35 36 37 |
# File 'lib/ruco/editor.rb', line 34 def save File.open(@file,'w'){|f| f.write(text_area.content) } @modified = false end |