Class: BridgetownNotion::Parsers::PostParser

Inherits:
Object
  • Object
show all
Defined in:
lib/bridgetown_notion/parsers/post_parser.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(post) ⇒ PostParser

Returns a new instance of PostParser.


8
9
10
# File 'lib/bridgetown_notion/parsers/post_parser.rb', line 8

def initialize(post)
  @post = post
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method_name) ⇒ Object


16
17
18
19
# File 'lib/bridgetown_notion/parsers/post_parser.rb', line 16

def method_missing(method_name)
  parser = method_name.to_s.camelize
  Object.const_get("BridgetownNotion::Parsers::#{parser}Parser").parse(@post)
end

Class Method Details

.parse(post) ⇒ Object


12
13
14
# File 'lib/bridgetown_notion/parsers/post_parser.rb', line 12

def self.parse(post)
  new(post)
end

Instance Method Details

#respond_to_missing?(method_name) ⇒ Boolean

Returns:

  • (Boolean)

21
22
23
24
25
# File 'lib/bridgetown_notion/parsers/post_parser.rb', line 21

def respond_to_missing?(method_name)
  Dir["./**/*_parser.rb"].each do |f|
    return true if f.include?(method_name)
  end
end