Class: Prick::Build::Node
- Inherits:
-
Object
- Object
- Prick::Build::Node
- Defined in:
- lib/builder/node.rb
Direct Known Subclasses
BuildNode, ExeNode, FoxNode, InlineNode, ModuleNode, SqlNode
Instance Attribute Summary collapse
-
#args ⇒ Object
readonly
only defined for :exe (String).
-
#kind ⇒ Object
readonly
:sql, :exe, :fox, :yml, :inline, :module.
-
#parent ⇒ Object
readonly
Returns the value of attribute parent.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
-
#phase ⇒ Object
readonly
:init, :decl, :seed, :term or nil (for BuildNode).
-
#source ⇒ Object
readonly
Returns the value of attribute source.
Instance Method Summary collapse
- #dump ⇒ Object
-
#initialize(parent, phase, kind, path, args = nil) ⇒ Node
constructor
A new instance of Node.
- #inspect ⇒ Object
- #lines ⇒ Object
- #name ⇒ Object
- #prefix_lines ⇒ Object
- #schema ⇒ Object
- #schema=(s) ⇒ Object
- #source_lines ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(parent, phase, kind, path, args = nil) ⇒ Node
Returns a new instance of Node.
32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/builder/node.rb', line 32 def initialize(parent, phase, kind, path, args = nil) constrain parent, BuildNode, NilClass constrain phase, :init, :decl, :seed, :term, nil constrain kind, :sql, :exe, :fox, :yml, :inline, :module constrain path, String, NilClass @parent, @phase, @kind, @path = parent, phase, kind, path @args = args&.empty? ? nil : args @schema = nil @source = nil @source_lines = nil end |
Instance Attribute Details
#args ⇒ Object (readonly)
only defined for :exe (String)
9 10 11 |
# File 'lib/builder/node.rb', line 9 def args @args end |
#kind ⇒ Object (readonly)
:sql, :exe, :fox, :yml, :inline, :module
7 8 9 |
# File 'lib/builder/node.rb', line 7 def kind @kind end |
#parent ⇒ Object (readonly)
Returns the value of attribute parent.
4 5 6 |
# File 'lib/builder/node.rb', line 4 def parent @parent end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
8 9 10 |
# File 'lib/builder/node.rb', line 8 def path @path end |
#phase ⇒ Object (readonly)
:init, :decl, :seed, :term or nil (for BuildNode)
6 7 8 |
# File 'lib/builder/node.rb', line 6 def phase @phase end |
#source ⇒ Object (readonly)
Returns the value of attribute source.
16 17 18 |
# File 'lib/builder/node.rb', line 16 def source @source end |
Instance Method Details
#dump ⇒ Object
46 |
# File 'lib/builder/node.rb', line 46 def dump() puts "#{inspect} (#{schema})" end |
#inspect ⇒ Object
45 |
# File 'lib/builder/node.rb', line 45 def inspect() to_s end |
#lines ⇒ Object
30 |
# File 'lib/builder/node.rb', line 30 def lines() prefix_lines + source_lines end |
#name ⇒ Object
11 |
# File 'lib/builder/node.rb', line 11 def name() @name = File.basename(path) end |
#prefix_lines ⇒ Object
22 |
# File 'lib/builder/node.rb', line 22 def prefix_lines() 0 end |
#schema ⇒ Object
13 |
# File 'lib/builder/node.rb', line 13 def schema() @schema ||= parent&.schema || "public" end |
#schema=(s) ⇒ Object
14 |
# File 'lib/builder/node.rb', line 14 def schema=(s) @schema = s end |
#source_lines ⇒ Object
24 25 26 27 28 |
# File 'lib/builder/node.rb', line 24 def source_lines() return @source_lines if @source_lines source @source_lines end |
#to_s ⇒ Object
44 |
# File 'lib/builder/node.rb', line 44 def to_s() [path, args].compact.join(" ") end |