Class: Jpmobile::HankakuFilter

Inherits:
Object
  • Object
show all
Defined in:
lib/jpmobile/filter.rb

Constant Summary collapse

ALLOWED_CONTENT_TYPE_REGEXP =
Regexp.union(
  Regexp.escape('text/html'),
  Regexp.escape('application/xhtml+xm'),
)
CONVERT_TARGET_ELEMENTS =
%w[submit reset button].freeze

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ HankakuFilter

Returns a new instance of HankakuFilter.



68
69
70
71
72
73
74
# File 'lib/jpmobile/filter.rb', line 68

def initialize(options = {})
  @options = {
    input: false,
  }.merge(options)

  @controller = nil
end

Class Method Details

.hankaku_format(str) ⇒ Object



48
49
50
# File 'lib/jpmobile/filter.rb', line 48

def hankaku_format(str)
  replace_chars(str, zen_to_han_table)
end

.zenkaku_format(str) ⇒ Object



52
53
54
# File 'lib/jpmobile/filter.rb', line 52

def zenkaku_format(str)
  replace_chars(str, han_to_zen_table)
end

Instance Method Details

#after(controller) ⇒ Object

内部コードから外部コードに変換



85
86
87
88
89
90
# File 'lib/jpmobile/filter.rb', line 85

def after(controller)
  @controller = controller
  if apply_outgoing? && @controller.response.body.is_a?(String)
    @controller.response.body = to_external(@controller.response.body)
  end
end

#before(controller) ⇒ Object



76
77
78
79
80
81
82
# File 'lib/jpmobile/filter.rb', line 76

def before(controller)
  @controller = controller

  if apply_incoming?
    @controller.params = convert_parameters(@controller.params.dup)
  end
end