Module: Kreuzberg::AnnotationKind

Overview

Types of inline text annotations.

Class Method Summary collapse

Class Method Details

.from_hash(hash) ⇒ Object



1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
# File 'lib/kreuzberg/native.rb', line 1513

def self.from_hash(hash)
  discriminator = hash[:annotation_type] || hash["annotation_type"]
  case discriminator
  when "bold" then AnnotationKindBold.from_hash(hash)
  when "italic" then AnnotationKindItalic.from_hash(hash)
  when "underline" then AnnotationKindUnderline.from_hash(hash)
  when "strikethrough" then AnnotationKindStrikethrough.from_hash(hash)
  when "code" then AnnotationKindCode.from_hash(hash)
  when "subscript" then AnnotationKindSubscript.from_hash(hash)
  when "superscript" then AnnotationKindSuperscript.from_hash(hash)
  when "link" then AnnotationKindLink.from_hash(hash)
  when "highlight" then AnnotationKindHighlight.from_hash(hash)
  when "color" then AnnotationKindColor.from_hash(hash)
  when "font_size" then AnnotationKindFontSize.from_hash(hash)
  when "custom" then AnnotationKindCustom.from_hash(hash)
  else raise "Unknown discriminator: #{discriminator}"
  end
end