Class: Jpmobile::HankakuFilter

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

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ 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

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



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

def after(controller)
  @controller = controller
  if apply_outgoing? and @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
83
# File 'lib/jpmobile/filter.rb', line 76

def before(controller)
  @controller = controller
  if apply_incoming?
    Util.deep_apply(@controller.params) do |value|
      value = to_internal(value)
    end
  end
end