Class: Interview::DatetimeAttribute

Inherits:
Attribute show all
Defined in:
lib/interview/datetime_attribute.rb

Instance Attribute Summary collapse

Attributes inherited from Attribute

#align, #caption, #caption_as_placeholder, #hide_caption, #hide_tooltip, #html_class, #link, #method, #nil_value, #on_changed, #only_for, #style, #surrounding_tag

Attributes inherited from Control

#parent

Instance Method Summary collapse

Methods inherited from Attribute

#initialize, #render, #tooltip, #value

Methods inherited from Control

#ancestors, build, definition, #find_attribute, #find_attribute!, inherited, #initialize, #render, #set_attributes, #set_defaults

Constructor Details

This class inherits a constructor from Interview::Attribute

Instance Attribute Details

#formatObject

Returns the value of attribute format.



4
5
6
# File 'lib/interview/datetime_attribute.rb', line 4

def format
  @format
end

Instance Method Details

#render_readObject



6
7
8
9
10
11
12
13
# File 'lib/interview/datetime_attribute.rb', line 6

def render_read
  return '' if value.nil?
  if @format
    return value.strftime(@format)
  else
    return h.l value
  end
end

#render_writeObject



15
16
17
# File 'lib/interview/datetime_attribute.rb', line 15

def render_write
  form_builder.date_select @method #, {}, {class: 'form-control'}
end