Class: Bgem::TargetFile
- Inherits:
-
Object
- Object
- Bgem::TargetFile
- Defined in:
- lib/bgem.rb
Instance Method Summary collapse
- #file ⇒ Object
-
#initialize(path = 'output.rb', scope = nil) ⇒ TargetFile
constructor
A new instance of TargetFile.
- #write(string) ⇒ Object
Constructor Details
#initialize(path = 'output.rb', scope = nil) ⇒ TargetFile
111 112 113 114 115 116 117 118 119 |
# File 'lib/bgem.rb', line 111 def initialize path = 'output.rb', scope = nil @path = Pathname path @scope = case scope when Array scope when String eval scope end end |
Instance Method Details
#file ⇒ Object
133 134 135 |
# File 'lib/bgem.rb', line 133 def file @path end |
#write(string) ⇒ Object
121 122 123 124 125 126 127 128 129 130 131 |
# File 'lib/bgem.rb', line 121 def write string @path.dirname.mkpath if @scope @scope.reverse_each do |head_of_constant_definition| string = "#{head_of_constant_definition}\n#{string.indent INDENT}\nend" end end @path.write "#{string}\n" end |