Class: Docbook::Mirror::Mark::Code

Inherits:
Base show all
Defined in:
lib/docbook/mirror/mark.rb,
lib/docbook/mirror/mark/code.rb

Overview

Code mark with role attribute to distinguish DocBook code types:

  • literal:
  • code:
  • userinput:
  • computeroutput:
  • filename:
  • classname:
  • function:
  • parameter:
  • replaceable:

Constant Summary collapse

PM_TYPE =
"code"

Constants inherited from Docbook::Mirror::Mark

MARKS, MARK_TYPES

Instance Attribute Summary

Attributes inherited from Docbook::Mirror::Mark

#attrs, #type

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Docbook::Mirror::Mark

#to_h, #to_json

Constructor Details

#initialize(role: "literal") ⇒ Code

Returns a new instance of Code.



69
70
71
72
# File 'lib/docbook/mirror/mark.rb', line 69

def initialize(role: "literal", **)
  super(**)
  @attrs[:role] = role
end

Class Method Details

.from_h(hash) ⇒ Object



78
79
80
81
82
83
84
# File 'lib/docbook/mirror/mark.rb', line 78

def self.from_h(hash)
  return nil unless hash

  attrs = hash["attrs"] || {}
  role = attrs[:role] || attrs["role"] || "literal"
  new(role: role)
end

Instance Method Details

#roleObject



74
75
76
# File 'lib/docbook/mirror/mark.rb', line 74

def role
  @attrs[:role]
end

#role=(value) ⇒ Object



30
31
32
# File 'lib/docbook/mirror/mark/code.rb', line 30

def role=(value)
  @attrs[:role] = value
end