Class: Clot::SelectMonth

Inherits:
NumberedTag show all
Defined in:
lib/clot/date_tags.rb

Instance Method Summary collapse

Methods inherited from NumberedTag

#can_show, #get_options, #id_string, #name_string, #render_string, #set_primary_attributes, #time_method

Methods inherited from ClotTag

#initialize, #render

Methods included from TagHelper

#resolve_value, #split_params

Methods included from AttributeSetter

#set_attributes, #set_primary_attributes

Constructor Details

This class inherits a constructor from Clot::ClotTag

Instance Method Details

#default_endObject



148
149
150
# File 'lib/clot/date_tags.rb', line 148

def default_end
  12
end

#default_field_nameObject



140
141
142
# File 'lib/clot/date_tags.rb', line 140

def default_field_name
  "month"
end

#default_startObject



144
145
146
# File 'lib/clot/date_tags.rb', line 144

def default_start
  1
end

#personal_attributes(name, value) ⇒ Object



152
153
154
155
156
157
158
159
160
161
162
163
# File 'lib/clot/date_tags.rb', line 152

def personal_attributes(name,value)
  case name
    when "use_month_numbers" then
      @use_month_numbers = value
    when "add_month_numbers" then
      @add_month_numbers = value
    when "use_short_month" then
      @use_short_month = value
    when "use_month_names" then
      @use_month_names = value
  end || super(name, value)
end

#value_string(val) ⇒ Object



165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
# File 'lib/clot/date_tags.rb', line 165

def value_string(val)
  if @use_month_numbers
    super(val)
  else
    if @use_month_names
      month_name = @use_month_names[val]
    else
      months = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]
      month_name = months[val - 1]
    end
    if @add_month_numbers
      "#{val} - #{month_name}"
    elsif @use_short_month
      month_name[0..2]
    else
      month_name
    end
  end
end