Class: AlWidget
- Inherits:
-
Object
- Object
- AlWidget
- Defined in:
- lib/al_form.rb
Overview
ウィジェット スーパークラス
Direct Known Subclasses
Instance Attribute Summary (collapse)
-
- (String) filter
入力フィルター.
-
- (Boolean) foreign
readonly
値が外部で生成されて、フォーム入力ではない事を示すフラグ.
-
- (Boolean) hidden
HTMLタグ input type=“hidden” として生成するかのフラグ.
-
- (String) label
ラベル.
-
- (String) message
readonly
メッセージ.
-
- (Symbol) name
readonly
識別名.
-
- (Boolean) required
readonly
必須入力フラグ.
-
- (Hash) tag_attr
Htmlタグ生成時のアトリビュート.
-
- (Object) value
入力値または初期値.
Instance Method Summary (collapse)
-
- (AlWidget) initialize(name, arg = {})
constructor
(AlWidget) constractor.
-
- (String) make_value(*arg)
(AlWidget) HTML値の生成.
-
- (Object) set_attr(arg)
(AlWidget) アトリビュートの設定.
-
- (Object) set_value(v)
(also: #value=)
(AlWidget) 値のセット.
Constructor Details
- (AlWidget) initialize(name, arg = {})
(AlWidget) constractor
597 598 599 600 601 602 603 604 605 606 607 |
# File 'lib/al_form.rb', line 597 def initialize( name, arg = {} ) @name = name.to_s @label = arg[:label] || @name @value = arg[:value] # (note) 初期値にはfilterをかける必要はないだろう @required = arg[:required] ? true: false @filter = arg[:filter] @tag_attr = arg[:tag_attr] || {} @foreign = arg[:foreign] ? true : false @hidden = arg[:hidden] ? true : false @message = "" end |
Instance Attribute Details
- (String) filter
入力フィルター
569 570 571 |
# File 'lib/al_form.rb', line 569 def filter @filter end |
- (Boolean) foreign (readonly)
値が外部で生成されて、フォーム入力ではない事を示すフラグ
575 576 577 |
# File 'lib/al_form.rb', line 575 def foreign @foreign end |
HTMLタグ input type=“hidden” として生成するかのフラグ
578 579 580 |
# File 'lib/al_form.rb', line 578 def @hidden end |
- (String) label
ラベル
560 561 562 |
# File 'lib/al_form.rb', line 560 def label @label end |
- (String) message (readonly)
メッセージ
581 582 583 |
# File 'lib/al_form.rb', line 581 def @message end |
- (Symbol) name (readonly)
識別名
557 558 559 |
# File 'lib/al_form.rb', line 557 def name @name end |
- (Boolean) required (readonly)
必須入力フラグ
566 567 568 |
# File 'lib/al_form.rb', line 566 def required @required end |
- (Hash) tag_attr
Htmlタグ生成時のアトリビュート
572 573 574 |
# File 'lib/al_form.rb', line 572 def tag_attr @tag_attr end |
- (Object) value
入力値または初期値
563 564 565 |
# File 'lib/al_form.rb', line 563 def value @value end |
Instance Method Details
- (String) make_value(*arg)
make_tag()との対称性をもたせるために存在する。
(AlWidget) HTML値の生成
643 644 645 |
# File 'lib/al_form.rb', line 643 def make_value( *arg ) return Alone::escape_html( arg.empty? ? @value: arg[0] ) end |
- (Object) set_attr(arg)
名称はsetだが、実質はaddである。 一貫していないようだが、テンプレートとの兼ね合いもあり、 この名称の方が自然に記述できる。
(AlWidget) アトリビュートの設定
630 631 632 |
# File 'lib/al_form.rb', line 630 def set_attr( arg ) @tag_attr.merge!( arg ) end |
- (Object) set_value(v) Also known as: value=
(AlWidget) 値のセット
615 616 617 |
# File 'lib/al_form.rb', line 615 def set_value( v ) @value = v end |