Class: AlTime

Inherits:
AlTimestamp show all
Defined in:
lib/al_form.rb

Overview

Note:

時刻ウィジェット

時分秒を扱う 内部的には日付を2000年に固定したTimeオブジェクトで保存する。

Constant Summary collapse

STRFTIME_FORMAT =
"%H:%M:%S"

Instance Attribute Summary

Attributes inherited from AlTimestamp

#max, #min

Attributes inherited from AlWidget

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

Instance Method Summary collapse

Methods inherited from AlTimestamp

#make_tag, #validate

Methods inherited from AlWidget

#make_tag, #set_attr, #set_value

Constructor Details

#initialize(name, arg = {}) ⇒ AlTime

(AlTime) constructor

Parameters:

  • name (String)

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

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

    引数ハッシュ

See Also:



1679
1680
1681
1682
# File 'lib/al_form.rb', line 1679

def initialize( name, arg = {} )
  super( name, arg )
  @value = normalize( @value )  if @value.class == Time
end

Instance Method Details

#make_value(*arg) ⇒ String

(AlTime) HTML値の生成

Parameters:

  • arg (String, Time)

    表示値。指定なければ内部値を使う。

Returns:

  • (String)

    html文字列



1691
1692
1693
1694
1695
1696
1697
1698
# File 'lib/al_form.rb', line 1691

def make_value( *arg )
  v = arg.empty? ? @value : arg[0]
  if v.class == Time
    return v.strftime('%H:%M:%S')
  else
    return Alone::escape_html( v )
  end
end