Class: Ezframe::PrefectureType

Inherits:
SelectType show all
Defined in:
lib/ezframe/column_type.rb

Instance Attribute Summary collapse

Attributes inherited from TypeBase

#attribute, #error, #parent

Instance Method Summary collapse

Methods inherited from SelectType

#db_type, #validate

Methods inherited from TypeBase

#db_type, #db_value, get_class, #key, #label, #multi_inputs?, #no_edit?, #no_view?, #normalize, #type, type_name, #use_view_format, #validate, #value, #value=

Constructor Details

#initialize(attr = nil) ⇒ PrefectureType

Returns a new instance of PrefectureType.



650
651
652
653
654
655
656
657
658
659
660
661
# File 'lib/ezframe/column_type.rb', line 650

def initialize(attr = nil)
  super(attr)
  @pref_a = %w[() 北海道 青森県 岩手県 宮城県 秋田県 山形県 福島県
               茨城県 栃木県 群馬県 埼玉県 千葉県 東京都 神奈川県
               新潟県 富山県 石川県 福井県 山梨県 長野県 岐阜県 静岡県 愛知県
               三重県 滋賀県 京都府 大阪府 兵庫県 奈良県 和歌山県
               鳥取県 島根県 岡山県 広島県 山口県
               徳島県 香川県 愛媛県 高知県
               福岡県 佐賀県 長崎県 熊本県 大分県 宮崎県 鹿児島県 沖縄県]
  @pref_h = {}
  @pref_a.each_with_index { |p, i| @pref_h[i] = p }
end

Instance Attribute Details

#pref_hObject

Returns the value of attribute pref_h.



648
649
650
# File 'lib/ezframe/column_type.rb', line 648

def pref_h
  @pref_h
end

Instance Method Details

#form(opts = {}) ⇒ Object



663
664
665
666
667
668
# File 'lib/ezframe/column_type.rb', line 663

def form(opts = {})
  return nil if no_edit? && !opts[:force]
  h = super
  h[:item] = @pref_h
  return h
end

#view(opts = {}) ⇒ Object



670
671
672
673
# File 'lib/ezframe/column_type.rb', line 670

def view(opts = {})
  return nil if no_view? && !opts[:force]
  return @pref_h[@value.to_i]
end