Class: Aozora2Html::Tag::Accent

Inherits:
Inline show all
Defined in:
lib/aozora2html/tag/accent.rb

Overview

欧文アクセント文字用

Class Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Aozora2Html::Tag

#inspect, #syntax_error

Constructor Details

#initialize(parser, code, name, gaiji_dir:) ⇒ Accent

Returns a new instance of Accent.



13
14
15
16
17
18
# File 'lib/aozora2html/tag/accent.rb', line 13

def initialize(parser, code, name, gaiji_dir:)
  @code = code
  @name = name
  @gaiji_dir = gaiji_dir
  super
end

Class Attribute Details

.use_jisx0213Object

Returns the value of attribute use_jisx0213.



10
11
12
# File 'lib/aozora2html/tag/accent.rb', line 10

def use_jisx0213
  @use_jisx0213
end

Instance Method Details

#char_typeObject



24
25
26
# File 'lib/aozora2html/tag/accent.rb', line 24

def char_type
  :hankaku
end

#jisx0213_to_unicode(code) ⇒ Object



20
21
22
# File 'lib/aozora2html/tag/accent.rb', line 20

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

#to_sObject



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

def to_s
  if Aozora2Html::Tag::Accent.use_jisx0213
    jisx0213_to_unicode(@code.sub(%r{.*/}, '').to_sym)
  else
    "<img src=\"#{@gaiji_dir}#{@code}.png\" alt=\"" + GAIJI_MARK + "(#{@name})\" class=\"gaiji\" />"
  end
end