Class: Bgem::Output
- Inherits:
-
Object
- Object
- Bgem::Output
- Defined in:
- lib/bgem.rb
Defined Under Namespace
Instance Method Summary collapse
-
#initialize(file = SOURCE_FILE, indent: 0) ⇒ Output
constructor
A new instance of Output.
- #to_s ⇒ Object
Constructor Details
#initialize(file = SOURCE_FILE, indent: 0) ⇒ Output
Returns a new instance of Output.
288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 |
# File 'lib/bgem.rb', line 288 def initialize file = SOURCE_FILE, indent: 0 file, @indent = (Pathname file), indent parts = file.basename.to_s.split '.' case parts.size when 3 name, type, file_extension = parts when 2 name, file_extension = parts else fail "#{file} has more than two dots in its name." end if Exts.const_defined? file_extension.upcase @output = Ext.new file_extension: file_extension, type: type, name: name, dir: file.dirname, code: file.read else fail "Don't know what to do with #{file}. Bgem::Output::Exts::#{file_extension.upcase} is not defined." end end |
Instance Method Details
#to_s ⇒ Object
309 310 311 |
# File 'lib/bgem.rb', line 309 def to_s @output.to_s.indent @indent end |