Class: DomainElement

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

Direct Known Subclasses

Controller, Model, Resource

Instance Attribute Summary collapse

Instance Method Summary collapse

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_locObject

Returns the value of attribute file_loc.



9
10
11
# File 'lib/rails_elements.rb', line 9

def file_loc
  @file_loc
end

#nameObject

Returns the value of attribute name.



9
10
11
# File 'lib/rails_elements.rb', line 9

def name
  @name
end

Instance Method Details

#generateObject



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