Class: Kut::Library::Pin

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

Overview

Implementation of Pin component

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(params = {}) ⇒ Pin

Parametrs name, number, pos, length, orientation, snum, snom, unit, convert, etype Example creation: Pin.new(:name => ‘PL2303’, :orientation => ‘U’, :pos => [15, 24])



39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/kut/library/components.rb', line 39

def initialize(params = {}) #name, number, posx, posy, length, orientation, snum, snom, unit, convert, etype
  if Hash === params
    @name = params[:name] ? params[:name] : '~' 
    @number = params[:number] ? params[:number] : '0'
    @pos = params[:pos] ? params[:pos] : [0, 0]
     @length = params[:length] ? params[:length] : 300
    @orientation = params[:orientation] ? params[:orientation] : 'R'
    @snum = params[:snum] ? params[:snum] : 40
    @snom = params[:snom] ? params[:snom] : 40
    @unit = params[:unit] ? params[:unit] : 0
    @convert = params[:convert] ? params[:convert] : 0
    @etype = params[:etype] ? params[:etype] : 'P'
  end
  #TODO implement raise exception
end

Instance Attribute Details

#convertObject

Returns the value of attribute convert.



35
36
37
# File 'lib/kut/library/components.rb', line 35

def convert
  @convert
end

#etypeObject

Returns the value of attribute etype.



35
36
37
# File 'lib/kut/library/components.rb', line 35

def etype
  @etype
end

#lengthObject

Returns the value of attribute length.



34
35
36
# File 'lib/kut/library/components.rb', line 34

def length
  @length
end

#nameObject

Returns the value of attribute name.



34
35
36
# File 'lib/kut/library/components.rb', line 34

def name
  @name
end

#numberObject

Returns the value of attribute number.



34
35
36
# File 'lib/kut/library/components.rb', line 34

def number
  @number
end

#orientationObject

Returns the value of attribute orientation.



35
36
37
# File 'lib/kut/library/components.rb', line 35

def orientation
  @orientation
end

#posObject

Returns the value of attribute pos.



34
35
36
# File 'lib/kut/library/components.rb', line 34

def pos
  @pos
end

#snomObject

Returns the value of attribute snom.



35
36
37
# File 'lib/kut/library/components.rb', line 35

def snom
  @snom
end

#snumObject

Returns the value of attribute snum.



35
36
37
# File 'lib/kut/library/components.rb', line 35

def snum
  @snum
end

#unitObject

Returns the value of attribute unit.



35
36
37
# File 'lib/kut/library/components.rb', line 35

def unit
  @unit
end

Instance Method Details

#to_sObject



55
56
57
# File 'lib/kut/library/components.rb', line 55

def to_s
  "X #{@name} #{@number} #{@pos[0]} #{@pos[1]} #{@length} #{@orientation} #{@snum} #{@snom} #{@unit} #{@convert} #{@etype}\n"
end