Class: Kut::Library::Polygon

Inherits:
Object
  • Object
show all
Defined in:
lib/kut/library/components.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(params = {}) ⇒ Polygon

:parts, :convert, :ltrait, :points, :cc



85
86
87
88
89
90
91
92
93
94
# File 'lib/kut/library/components.rb', line 85

def initialize(params = {}) #:parts, :convert, :ltrait, :points, :cc
  if Hash === params
    @parts = params[:parts] ? params[:parts] : 0
    @points = params[:points] ? params[:points] : []
    @convert = params[:convert] ? params[:convert] : 0
    @ltrait = params[:ltrait] ? params[:ltrait] : 0
    @cc = params[:cc] ? params[:cc] : 'N'
  end
  #TODO implement raise exception
end

Instance Attribute Details

#ccObject

Returns the value of attribute cc.



83
84
85
# File 'lib/kut/library/components.rb', line 83

def cc
  @cc
end

#convertObject

Returns the value of attribute convert.



82
83
84
# File 'lib/kut/library/components.rb', line 82

def convert
  @convert
end

#ltraitObject

Returns the value of attribute ltrait.



82
83
84
# File 'lib/kut/library/components.rb', line 82

def ltrait
  @ltrait
end

#partsObject

Returns the value of attribute parts.



82
83
84
# File 'lib/kut/library/components.rb', line 82

def parts
  @parts
end

#pointsObject

Returns the value of attribute points.



83
84
85
# File 'lib/kut/library/components.rb', line 83

def points
  @points
end

Instance Method Details

#to_sObject



96
97
98
99
100
101
102
# File 'lib/kut/library/components.rb', line 96

def to_s
  result = "P #{@points.length} #{@parts} #{@convert} #{@ltrait}"
  @points.each { |point|
    result += " #{point[0]} #{point[1]}"
  }
  result += " #{@cc}\n"
end