class Forematter::Commands::Touch

Public Instance Methods

run() click to toggle source
# File lib/forematter/commands/touch.rb, line 37
def run
  files_with(field).each do |file|
    file[field] = now
    file.write
  end
end

Protected Instance Methods

format_now() click to toggle source
# File lib/forematter/commands/touch.rb, line 50
def format_now
  format = options[:format] || 'iso8601'
  now    = options.key?(:time) ? Time.new(options[:time]) : Time.now

  case format
  when 'date'    then now
  when 'iso8601' then now.to_datetime.iso8601
  when 'db'      then now.strftime('%Y-%m-%d %H:%M:%S')
  else
    now.strftime(format)
  end
end
now() click to toggle source
# File lib/forematter/commands/touch.rb, line 46
def now
  @now ||= format_now
end