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, app_name = nil) ⇒ FileReader
constructor
A new instance of FileReader.
Constructor Details
#initialize(file, app_name = nil) ⇒ FileReader
Returns a new instance of FileReader.
102 103 104 105 |
# File 'lib/crafti.rb', line 102 def initialize(file, app_name = nil) ::Crafti::AppName.name(app_name) @content = ::Pathname.new(file.to_s)..read end |
Instance Attribute Details
#content ⇒ Object (readonly)
Returns the value of attribute content.
101 102 103 |
# File 'lib/crafti.rb', line 101 def content @content end |
Class Method Details
.generate(file, app_name = nil) ⇒ Object
96 97 98 99 |
# File 'lib/crafti.rb', line 96 def self.generate(file, app_name = nil) app = new(file, app_name) app.evaluate end |
Instance Method Details
#evaluate ⇒ Object
107 108 109 110 111 112 113 114 115 116 117 |
# File 'lib/crafti.rb', line 107 def evaluate klass = Class.new do Kernel.extend(Crafti::KernelExtension) Kernel.extend(Crafti::AppName) def self.execute(string) eval string end end klass.execute(content) end |