Class: Crafti::FileReader
- Inherits:
-
Object
- Object
- Crafti::FileReader
- Defined in:
- lib/crafti.rb
Instance Attribute Summary collapse
-
#content ⇒ Object
readonly
Returns the value of attribute content.
Class Method Summary collapse
Instance Method Summary collapse
- #evaluate ⇒ Object
-
#initialize(file) ⇒ FileReader
constructor
A new instance of FileReader.
Constructor Details
#initialize(file) ⇒ FileReader
Returns a new instance of FileReader.
88 89 90 |
# File 'lib/crafti.rb', line 88 def initialize(file) @content = ::Pathname.new(file.to_s)..read end |
Instance Attribute Details
#content ⇒ Object (readonly)
Returns the value of attribute content.
87 88 89 |
# File 'lib/crafti.rb', line 87 def content @content end |
Class Method Details
.generate(file) ⇒ Object
82 83 84 85 |
# File 'lib/crafti.rb', line 82 def self.generate(file) app = new(file) app.evaluate end |
Instance Method Details
#evaluate ⇒ Object
92 93 94 95 96 97 98 99 100 101 |
# File 'lib/crafti.rb', line 92 def evaluate klass = Class.new do ::Kernel.extend(Crafti::KernelExtension) def self.execute(string) eval string end end klass.execute(content) end |