Class: Onload::File
Instance Attribute Summary collapse
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Instance Method Summary collapse
-
#initialize(path) ⇒ File
constructor
A new instance of File.
- #outfile ⇒ Object
- #write ⇒ Object
Constructor Details
#initialize(path) ⇒ File
Returns a new instance of File.
7 8 9 |
# File 'lib/onload/file.rb', line 7 def initialize(path) @path = path end |
Instance Attribute Details
#path ⇒ Object (readonly)
Returns the value of attribute path.
5 6 7 |
# File 'lib/onload/file.rb', line 5 def path @path end |
Instance Method Details
#outfile ⇒ Object
21 22 23 24 25 26 |
# File 'lib/onload/file.rb', line 21 def outfile @outfile ||= begin base_name = "#{Onload.basename(path)}.rb" ::File.join(::File.dirname(path), base_name) end end |
#write ⇒ Object
11 12 13 14 15 16 17 18 19 |
# File 'lib/onload/file.rb', line 11 def write source = ::File.read(path) ::File.extname(path).scan(/\.\w+/).each do |ext| source = Onload.processors[ext].call(source) end ::File.write(outfile, source) end |