Class: AlNumber

Inherits:
AlWidget show all
Defined in:
lib/al_form.rb,
lib/al_form/extend.rb

Overview

数値入力ウィジェット

Direct Known Subclasses

AlFloat, AlInteger

Instance Attribute Summary (collapse)

Attributes inherited from AlWidget

#filter, #foreign, #hidden, #label, #message, #name, #required, #tag_attr, #value

Instance Method Summary (collapse)

Methods inherited from AlWidget

#make_value, #set_attr, #set_value

Constructor Details

- (AlNumber) initialize(name, arg = {})

(AlNumber) constractor

AlWidget#initialize argは親クラスも参照

Parameters:

  • name (String)

    ウィジェット識別名 英文字を推奨

  • arg (Hash) (defaults to: {})

    引数ハッシュ

Options Hash (arg):

  • :max (Integer)

    最大値

  • :min (Integer)

    最小値

See Also:



1345
1346
1347
1348
1349
1350
1351
# File 'lib/al_form.rb', line 1345

def initialize( name, arg = {} )
  require 'al_form/extend'

  super( name, arg )
  @max = arg[:max]
  @min = arg[:min]
end

Instance Attribute Details

- (Integer) max

Returns 最大値

Returns:

  • (Integer)

    最大値



18
19
20
# File 'lib/al_form/extend.rb', line 18

def max
  @max
end

- (Integer) min

Returns 最小値

Returns:

  • (Integer)

    最小値



21
22
23
# File 'lib/al_form/extend.rb', line 21

def min
  @min
end

Instance Method Details

- (String) make_tag(arg = {})

(AlNumber) HTMLタグの生成

Parameters:

  • arg (Hash) (defaults to: {})

    htmlタグへ追加するアトリビュートを指定

Returns:

  • (String)

    htmlタグ



30
31
32
33
34
35
36
37
38
39
40
# File 'lib/al_form/extend.rb', line 30

def make_tag( arg = {} )
  if @hidden
    return %Q(<input type="hidden" name="#{@name}" id="#{@name}" value="#{Alone::escape_html( @value )}" #{AL_FORM_EMPTYTAG_CLOSE}\n)
  end

  r = %Q(<input type="text" name="#{@name}" id="#{@name}" value="#{Alone::escape_html( @value )}")
  (@tag_attr.merge arg).each do |k,v|
    r << %Q( #{k}="#{Alone::escape_html(v)}")
  end
  return "#{r} #{AL_FORM_EMPTYTAG_CLOSE}"
end