Class: Rux::File

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

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#pathObject (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_outfileObject



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