Class: Crafti::FileReader

Inherits:
Object
  • Object
show all
Defined in:
lib/crafti.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

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).expand_path.read
end

Instance Attribute Details

#contentObject (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

#evaluateObject



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