Class: Rux::File
- Inherits:
-
Object
- Object
- Rux::File
- Defined in:
- lib/rux/file.rb
Instance Attribute Summary collapse
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Instance Method Summary collapse
- #default_outfile ⇒ Object
-
#initialize(path) ⇒ File
constructor
A new instance of File.
- #to_ruby(visitor: Rux.default_visitor, **kwargs) ⇒ Object
- #write(outfile = nil, **kwargs) ⇒ Object
Constructor Details
#initialize(path) ⇒ File
Returns a new instance of File.
5 6 7 |
# File 'lib/rux/file.rb', line 5 def initialize(path) @path = path end |
Instance Attribute Details
#path ⇒ Object (readonly)
Returns the value of attribute path.
3 4 5 |
# File 'lib/rux/file.rb', line 3 def path @path end |
Instance Method Details
#default_outfile ⇒ Object
17 18 19 |
# File 'lib/rux/file.rb', line 17 def default_outfile @outfile ||= "#{path.chomp('.rux')}.rb" end |
#to_ruby(visitor: Rux.default_visitor, **kwargs) ⇒ Object
9 10 11 |
# File 'lib/rux/file.rb', line 9 def to_ruby(visitor: Rux.default_visitor, **kwargs) Rux.to_ruby(contents, visitor: visitor, **kwargs) end |
#write(outfile = nil, **kwargs) ⇒ Object
13 14 15 |
# File 'lib/rux/file.rb', line 13 def write(outfile = nil, **kwargs) ::File.write(outfile || default_outfile, to_ruby(**kwargs)) end |