Class: SlideHero::Code

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

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#languageObject (readonly)

Returns the value of attribute language.



3
4
5
# File 'lib/slide_hero/code.rb', line 3

def language
  @language
end

#locationObject (readonly)

Returns the value of attribute location.



3
4
5
# File 'lib/slide_hero/code.rb', line 3

def location
  @location
end

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

#compileObject



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