Class: DomainElement
- Inherits:
-
Object
- Object
- DomainElement
- Defined in:
- lib/rails_elements.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#file_loc ⇒ Object
Returns the value of attribute file_loc.
-
#name ⇒ Object
Returns the value of attribute name.
Instance Method Summary collapse
- #generate ⇒ Object
-
#initialize(name) ⇒ DomainElement
constructor
A new instance of DomainElement.
- #insert_after(filename, regex, new_content) ⇒ Object
Constructor Details
#initialize(name) ⇒ DomainElement
Returns a new instance of DomainElement.
10 11 12 |
# File 'lib/rails_elements.rb', line 10 def initialize name @name = name end |
Instance Attribute Details
#file_loc ⇒ Object
Returns the value of attribute file_loc.
9 10 11 |
# File 'lib/rails_elements.rb', line 9 def file_loc @file_loc end |
#name ⇒ Object
Returns the value of attribute name.
9 10 11 |
# File 'lib/rails_elements.rb', line 9 def name @name end |
Instance Method Details
#generate ⇒ Object
24 25 |
# File 'lib/rails_elements.rb', line 24 def generate end |
#insert_after(filename, regex, new_content) ⇒ Object
14 15 16 17 18 19 20 21 22 |
# File 'lib/rails_elements.rb', line 14 def insert_after(filename, regex, new_content) contents = '' file = File.read(filename) file.each { |line| contents << line contents << new_content if line =~ regex } write contents, filename end |