Class: BobTest::BobTest
- Inherits:
-
Object
- Object
- BobTest::BobTest
- Defined in:
- lib/bob_test.rb
Overview
need to figure out what File.open(‘/path/to/file’, ‘wb’ ) does # the wb part. (w means write, b means binary) commands.rb in rails source
Instance Attribute Summary collapse
-
#contents ⇒ Object
Returns the value of attribute contents.
-
#end_line ⇒ Object
Returns the value of attribute end_line.
-
#indentable_words ⇒ Object
Returns the value of attribute indentable_words.
-
#name ⇒ Object
Returns the value of attribute name.
-
#start_line ⇒ Object
Returns the value of attribute start_line.
Instance Method Summary collapse
Instance Attribute Details
#contents ⇒ Object
Returns the value of attribute contents.
37 38 39 |
# File 'lib/bob_test.rb', line 37 def contents @contents end |
#end_line ⇒ Object
Returns the value of attribute end_line.
37 38 39 |
# File 'lib/bob_test.rb', line 37 def end_line @end_line end |
#indentable_words ⇒ Object
Returns the value of attribute indentable_words.
37 38 39 |
# File 'lib/bob_test.rb', line 37 def indentable_words @indentable_words end |
#name ⇒ Object
Returns the value of attribute name.
37 38 39 |
# File 'lib/bob_test.rb', line 37 def name @name end |
#start_line ⇒ Object
Returns the value of attribute start_line.
37 38 39 |
# File 'lib/bob_test.rb', line 37 def start_line @start_line end |
Instance Method Details
#get_lines(lines = []) ⇒ Object
42 43 44 45 46 47 48 49 |
# File 'lib/bob_test.rb', line 42 def get_lines(lines = []) out = [] lines = lines.to_a if lines.is_a? Range lines.each do |l| out << Readline::HISTORY[l] end @contents = out end |
#write_to_file(file) ⇒ Object
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/bob_test.rb', line 51 def write_to_file(file) File.open(file, 'r+') do |f| lines = f.readlines e = lines.pop until e.eql?("end\n") e = lines.pop break if lines.empty? end f.pos = 0 f.write lines f.write " def #{name.gsub(/\W/,'_')}\n" @contents.each do |line| f.write " #{line}\n" end f.write " end\n" f.write e f.truncate f.pos end # gonna have to run a file indenter ! # gotta figure out how to load the files this produces # pluginify this end |