Class: RicherText::Mark

Inherits:
Object
  • Object
show all
Defined in:
lib/richer_text/mark.rb

Constant Summary collapse

TAGS =
{
  "bold" => "strong",
  "italic" => "em",
  "strike" => "del",
  "code" => "code",
  "highlight" => "mark",
  "link" => "a"
}

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(json) ⇒ Mark

Returns a new instance of Mark.



14
15
16
17
# File 'lib/richer_text/mark.rb', line 14

def initialize(json)
  @attrs = json.fetch("attrs", {})
  @type = json.fetch("type", nil)
end

Instance Attribute Details

#attrsObject (readonly)

Returns the value of attribute attrs.



3
4
5
# File 'lib/richer_text/mark.rb', line 3

def attrs
  @attrs
end

#typeObject (readonly)

Returns the value of attribute type.



3
4
5
# File 'lib/richer_text/mark.rb', line 3

def type
  @type
end

Instance Method Details

#tagObject



19
20
21
# File 'lib/richer_text/mark.rb', line 19

def tag
  TAGS[type] || "span"
end