Class: Repubmark::Elems::CodeInline

Inherits:
Base
  • Object
show all
Defined in:
lib/repubmark/elems/code_inline.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, #word_count

Constructor Details

#initialize(parent, str) ⇒ CodeInline

Returns a new instance of CodeInline.



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

def initialize(parent, str)
  super parent
  self.str = str
end

Instance Method Details

#str=(str) ⇒ Object (private)



25
26
27
28
29
30
31
32
# File 'lib/repubmark/elems/code_inline.rb', line 25

def str=(str)
  str = String(str).freeze
  if str.include?("\n") || str.include?('«') || str.include?('»')
    raise 'Invalid str'
  end

  @str = str
end

#to_gemtextObject



21
# File 'lib/repubmark/elems/code_inline.rb', line 21

def to_gemtext = "«#{@str}»".freeze

#to_htmlObject



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

def to_html = "<code>#{CGI.escape_html(@str)}</code>".freeze

#to_summary_plainObject

Basic methods #



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

def to_summary_plain = "«#{@str}»".freeze