Class: Lecture::Slide::Base

Inherits:
Object
  • Object
show all
Includes:
Terminal
Defined in:
lib/lecture/slide/base.rb

Direct Known Subclasses

Block, Center, Code, Section

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(content:, **options) ⇒ Base

Returns a new instance of Base.



16
17
18
19
# File 'lib/lecture/slide/base.rb', line 16

def initialize(content:, **options)
  @content = content
  @options = options.with_indifferent_access
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method_name, *arguments, &block) ⇒ Object (private)



30
31
32
33
34
35
36
# File 'lib/lecture/slide/base.rb', line 30

def method_missing(method_name, *arguments, &block)
  if options.key?(method_name)
    options[method_name]
  else
    super
  end
end

Instance Attribute Details

#contentObject

Returns the value of attribute content.



8
9
10
# File 'lib/lecture/slide/base.rb', line 8

def content
  @content
end

#optionsObject

Returns the value of attribute options.



8
9
10
# File 'lib/lecture/slide/base.rb', line 8

def options
  @options
end

Class Method Details

.inherited(base) ⇒ Object



11
12
13
# File 'lib/lecture/slide/base.rb', line 11

def inherited(base)
  Lecture.slide_types.add(base.to_s.demodulize.downcase.to_sym)
end

Instance Method Details

#displayObject

Raises:

  • (NotImplementedError)


21
22
23
24
25
26
# File 'lib/lecture/slide/base.rb', line 21

def display
  raise(
    NotImplementedError,
    "self.#{__method__} must be implemented by including class."
  )
end