Class: Nix::NixBuilder
- Inherits:
-
Object
- Object
- Nix::NixBuilder
- Defined in:
- lib/vagrant-nixos/nix.rb
Instance Attribute Summary collapse
-
#exprs ⇒ Object
Returns the value of attribute exprs.
-
#parent ⇒ Object
Returns the value of attribute parent.
Instance Method Summary collapse
-
#initialize(parent, expr, *args) ⇒ NixBuilder
constructor
A new instance of NixBuilder.
- #method_missing(m, *args, &block) ⇒ Object
- #to_nix(indent = 0) ⇒ Object
Constructor Details
#initialize(parent, expr, *args) ⇒ NixBuilder
Returns a new instance of NixBuilder.
18 19 20 21 |
# File 'lib/vagrant-nixos/nix.rb', line 18 def initialize(parent, expr, *args) @parent = parent @exprs = args.inject([expr]){|exs, e| exs << e} end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(m, *args, &block) ⇒ Object
23 24 25 |
# File 'lib/vagrant-nixos/nix.rb', line 23 def method_missing(m, *args, &block) NixBuilder.new(self, m.to_sym, *args) end |
Instance Attribute Details
#exprs ⇒ Object
Returns the value of attribute exprs.
15 16 17 |
# File 'lib/vagrant-nixos/nix.rb', line 15 def exprs @exprs end |
#parent ⇒ Object
Returns the value of attribute parent.
16 17 18 |
# File 'lib/vagrant-nixos/nix.rb', line 16 def parent @parent end |
Instance Method Details
#to_nix(indent = 0) ⇒ Object
27 28 29 30 31 32 33 34 35 36 |
# File 'lib/vagrant-nixos/nix.rb', line 27 def to_nix(indent = 0) s = "" s << "(" if @exprs[0] == :import if @parent s = @parent.to_nix << "." end s << @exprs.map{|e| e.to_nix}.join(" ") s << ")" if @exprs[0] == :import s end |