Class: Aozora2Html::Tag::EmbedGaiji

Inherits:
Gaiji show all
Defined in:
lib/aozora2html/tag/embed_gaiji.rb

Overview

外字注記用

Class Attribute Summary collapse

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Gaiji

#char_type

Methods inherited from Aozora2Html::Tag

#char_type, #inspect, #syntax_error

Constructor Details

#initialize(parser, folder, code, name, unicode_num = nil, gaiji_dir:) ⇒ EmbedGaiji

Returns a new instance of EmbedGaiji.



28
29
30
31
32
33
34
35
# File 'lib/aozora2html/tag/embed_gaiji.rb', line 28

def initialize(parser, folder, code, name, unicode_num = nil, gaiji_dir:)
  @folder = folder
  @code = code
  @name = name
  @unicode = unicode_num
  @gaiji_dir = gaiji_dir
  super
end

Class Attribute Details

.use_jisx0213Object

Returns the value of attribute use_jisx0213.



17
18
19
# File 'lib/aozora2html/tag/embed_gaiji.rb', line 17

def use_jisx0213
  @use_jisx0213
end

.use_unicodeObject

Returns the value of attribute use_unicode.



25
26
27
# File 'lib/aozora2html/tag/embed_gaiji.rb', line 25

def use_unicode
  @use_unicode
end

Instance Attribute Details

#unicodeObject

Returns the value of attribute unicode.



7
8
9
# File 'lib/aozora2html/tag/embed_gaiji.rb', line 7

def unicode
  @unicode
end

Instance Method Details

#jisx0213_to_unicode(code) ⇒ Object



37
38
39
# File 'lib/aozora2html/tag/embed_gaiji.rb', line 37

def jisx0213_to_unicode(code)
  Aozora2Html::JIS2UCS[code]
end

#to_sObject



41
42
43
44
45
46
47
48
49
# File 'lib/aozora2html/tag/embed_gaiji.rb', line 41

def to_s
  if Aozora2Html::Tag::EmbedGaiji.use_jisx0213 && @code
    jisx0213_to_unicode(@code.to_sym)
  elsif Aozora2Html::Tag::EmbedGaiji.use_unicode && @unicode
    "&#x#{@unicode};"
  else
    "<img src=\"#{@gaiji_dir}#{@folder}/#{@code}.png\" alt=\"" + GAIJI_MARK + "(#{@name})\" class=\"gaiji\" />"
  end
end