Class: Bike::Meta::Timestamp
- Includes:
- Bike::Meta
- Defined in:
- lib/meta/timestamp.rb
Constant Summary collapse
- REX_DATE =
/\A(\d+).(\d+).(\d+)(?:[T\s](\d+):(\d+)(?::(\d+))?)?\z/
Constants inherited from Field
Instance Attribute Summary
Attributes inherited from Field
Instance Method Summary collapse
- #errors ⇒ Object
-
#initialize(meta = {}) ⇒ Timestamp
constructor
A new instance of Timestamp.
Methods included from Bike::Meta
Methods inherited from Field
#[], #[]=, #commit, #create, #default_action, #delete, #empty?, #find_ancestor, #get, h, #inspect, instance, #item, #load, #load_default, #meta_admins, #meta_client, #meta_folder, #meta_full_name, #meta_group, #meta_name, #meta_owner, #meta_owners, #meta_roles, #meta_sd, #meta_short_name, #pending?, #permit?, #post, #update, #val, #valid?, #workflow
Methods included from I18n
_, bindtextdomain, domain, domain=, find_msg, lang, lang=, merge_msg!, msg, n_, parse_msg, po_dir, po_dir=
Constructor Details
#initialize(meta = {}) ⇒ Timestamp
Returns a new instance of Timestamp.
14 15 16 17 18 19 |
# File 'lib/meta/timestamp.rb', line 14 def initialize( = {}) [:size] = $&.to_i if [:tokens] && [:tokens].find {|t| t =~ /^\d+$/ } [:can_edit] = true if Array([:tokens]).include? 'can_edit' [:can_update] = true if Array([:tokens]).include? 'can_update' super end |
Instance Method Details
#errors ⇒ Object
21 22 23 24 25 26 27 28 29 |
# File 'lib/meta/timestamp.rb', line 21 def errors if @date_str.nil? [] elsif @date_str =~ REX_DATE (Time.local($1, $2, $3, $4, $5, $6) rescue nil) ? [] : ['out of range'] else ['wrong format'] end end |