Class: HS::Code

Inherits:
Element show all
Defined in:
lib/hs/elements/code.rb

Instance Attribute Summary collapse

Attributes inherited from Element

#children, #class_name, #style

Instance Method Summary collapse

Methods inherited from Element

#initialize, #preview

Methods included from ElementPreview

#element_preview, #text_preview

Constructor Details

This class inherits a constructor from HS::Element

Instance Attribute Details

#langObject

Returns the value of attribute lang.



5
6
7
# File 'lib/hs/elements/code.rb', line 5

def lang
  @lang
end

Instance Method Details

#inline?Boolean

Returns:

  • (Boolean)


7
8
9
# File 'lib/hs/elements/code.rb', line 7

def inline?
  lang.nil?
end

#paramsObject



15
16
17
18
19
20
# File 'lib/hs/elements/code.rb', line 15

def params
  params = super
  return params if inline?

  params.merge(lang: lang)
end

#tag_nameObject



11
12
13
# File 'lib/hs/elements/code.rb', line 11

def tag_name
  inline? ? 'code' : 'pre'
end