Class: Repubmark::Elems::Annotation

Inherits:
Base
  • Object
show all
Defined in:
lib/repubmark/elems/annotation.rb

Instance Attribute Summary

Attributes inherited from Base

#parent

Instance Method Summary collapse

Methods inherited from Base

#absolute_url, #config, #count_words, #html_class, #own_url, parent?, parents, #relative_url

Constructor Details

#initialize(parent) ⇒ Annotation

Returns a new instance of Annotation.



8
9
10
11
# File 'lib/repubmark/elems/annotation.rb', line 8

def initialize(parent)
  super parent
  @canvas = Canvas.new self
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method_name) ⇒ Object



39
40
41
42
43
44
45
# File 'lib/repubmark/elems/annotation.rb', line 39

def method_missing(method_name, ...)
  if @canvas.respond_to? method_name
    @canvas.public_send(method_name, ...)
  else
    super
  end
end

Instance Method Details

#respond_to_missing?(method_name, _include_private) ⇒ Boolean

Builder methods #

Returns:

  • (Boolean)


35
36
37
# File 'lib/repubmark/elems/annotation.rb', line 35

def respond_to_missing?(method_name, _include_private)
  @canvas.respond_to?(method_name) || super
end

#to_gemtextObject



29
# File 'lib/repubmark/elems/annotation.rb', line 29

def to_gemtext = @canvas.to_gemtext

#to_htmlObject



21
22
23
24
25
26
27
# File 'lib/repubmark/elems/annotation.rb', line 21

def to_html
  [
    %(<div#{html_class(:annotation)}>\n),
    @canvas.to_html,
    "</div>\n",
  ].join.freeze
end

#to_summary_plainObject



19
# File 'lib/repubmark/elems/annotation.rb', line 19

def to_summary_plain = @canvas.to_summary_plain

#word_countObject

Basic methods #



17
# File 'lib/repubmark/elems/annotation.rb', line 17

def word_count = @canvas.word_count