Class: Towsta::Kinds::VerticalKind

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

Instance Attribute Summary

Attributes inherited from MainKind

#content

Instance Method Summary collapse

Methods inherited from MainKind

#compare_parameterized, #initialize, #kind

Constructor Details

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

Instance Method Details

#compare(object) ⇒ Object



25
26
27
28
# File 'lib/towsta/kinds/vertical.rb', line 25

def compare object
  self.get.id.to_i == object.id.to_i if Towsta::Core.subclasses.include? object.class
  self.get == object
end

#exportObject



30
31
32
33
# File 'lib/towsta/kinds/vertical.rb', line 30

def export
  return @content.id.to_s if Towsta::Core.subclasses.include? self.get.class
  @content.to_s
end

#getObject



6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/towsta/kinds/vertical.rb', line 6

def get
  return nil unless @content
  return @content if @content.class != Fixnum
  Towsta::Core.subclasses.each do |v|
    horizontal = v.find_by_id @content
    if horizontal
      @content = horizontal
      return horizontal
    end
  end
  nil
end

#set(content) ⇒ Object



19
20
21
22
23
# File 'lib/towsta/kinds/vertical.rb', line 19

def set content
  return @content = nil if !!(content =~ /[^0-9]/)
  return @content = content if Towsta::Core.subclasses.include? content.class
  @content = content.to_i
end