Class: Towsta::Kinds::DateKind

Inherits:
MainKind
  • Object
show all
Defined in:
lib/towsta/kinds/date.rb

Instance Attribute Summary

Attributes inherited from MainKind

#content

Instance Method Summary collapse

Methods inherited from MainKind

#compare, #compare_parameterized, #get, #initialize, #kind

Constructor Details

This class inherits a constructor from Towsta::Kinds::MainKind

Instance Method Details

#exportObject



15
16
17
18
# File 'lib/towsta/kinds/date.rb', line 15

def export
  return @content.strftime('%m/%d/%Y') if content.class == DateTime
  @content.to_s
end

#set(content) ⇒ Object



6
7
8
9
10
11
12
13
# File 'lib/towsta/kinds/date.rb', line 6

def set content
  return @content = content if content.class == DateTime
  begin
    @content = DateTime.strptime(content, '%m/%d/%Y')
  rescue
    @content = nil
  end
end