Class: Copypasta::Entry::ERB
Instance Attribute Summary collapse
-
#locals ⇒ Object
readonly
Returns the value of attribute locals.
-
#source ⇒ Object
readonly
Returns the value of attribute source.
Attributes inherited from Base
Instance Method Summary collapse
-
#initialize(filename, directory:, locals: {}, source: nil, only_if: nil) ⇒ ERB
constructor
A new instance of ERB.
Methods inherited from Base
Constructor Details
#initialize(filename, directory:, locals: {}, source: nil, only_if: nil) ⇒ ERB
Returns a new instance of ERB.
11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/copypasta/entry/erb.rb', line 11 def initialize(filename, directory:, locals: {}, source: nil, only_if: nil) raise "filename must be a string." unless filename.is_a?(String) raise "only_if must be null or a Proc." if !only_if.nil? && !only_if.is_a?(Proc) raise "locals must be a Hash." unless locals.is_a?(Hash) @filename = filename.dup.freeze @directory = directory.dup.freeze @locals = locals.dup.freeze @source = (source || "#{filename}.erb").dup.freeze @only_if = only_if end |
Instance Attribute Details
#locals ⇒ Object (readonly)
Returns the value of attribute locals.
9 10 11 |
# File 'lib/copypasta/entry/erb.rb', line 9 def locals @locals end |
#source ⇒ Object (readonly)
Returns the value of attribute source.
8 9 10 |
# File 'lib/copypasta/entry/erb.rb', line 8 def source @source end |