Class: SlideHero::Code
- Inherits:
-
Object
- Object
- SlideHero::Code
- Defined in:
- lib/slide_hero/code.rb
Instance Attribute Summary collapse
-
#language ⇒ Object
readonly
Returns the value of attribute language.
-
#location ⇒ Object
readonly
Returns the value of attribute location.
-
#source ⇒ Object
readonly
Returns the value of attribute source.
Instance Method Summary collapse
- #compile ⇒ Object
-
#initialize(language, code_path = Dir.pwd, &code_file) ⇒ Code
constructor
A new instance of Code.
Constructor Details
#initialize(language, code_path = Dir.pwd, &code_file) ⇒ Code
Returns a new instance of Code.
4 5 6 7 8 9 10 |
# File 'lib/slide_hero/code.rb', line 4 def initialize(language, code_path=Dir.pwd, &code_file) @language = language @location = "#{code_path}/code/#{code_file.call}" @source = File.read(location) rescue Errno::ENOENT abort "#{Dir.pwd}/#{code_file.call} not found" end |
Instance Attribute Details
#language ⇒ Object (readonly)
Returns the value of attribute language.
3 4 5 |
# File 'lib/slide_hero/code.rb', line 3 def language @language end |
#location ⇒ Object (readonly)
Returns the value of attribute location.
3 4 5 |
# File 'lib/slide_hero/code.rb', line 3 def location @location end |
#source ⇒ Object (readonly)
Returns the value of attribute source.
3 4 5 |
# File 'lib/slide_hero/code.rb', line 3 def source @source end |
Instance Method Details
#compile ⇒ Object
12 13 14 15 16 |
# File 'lib/slide_hero/code.rb', line 12 def compile Tilt::ERBTemplate. new(File.join(SlideHero.template_path, 'lib/slide_hero/views/code.html.erb')).render(self) end |