Class: Kut::Library::Component

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(params = {}) ⇒ Component

Returns a new instance of Component.



130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
# File 'lib/kut/library/components.rb', line 130

def initialize(params = {})
  if Hash === params
    @name = params[:name] ? params[:name] : '' 
    @reference = params[:reference] ? params[:reference] : 'U'
    @text_offset = params[:text_offset] ? params[:text_offset] : 30
    @draw_pinnumber = params[:draw_pinnumber] ? params[:draw_pinnumber] : 'Y'
    @draw_pinname = params[:draw_pinname] ? params[:draw_pinname] : 'Y'
    @unit_count = params[:unit_count] ? params[:unit_count] : 1
    @units_locked = params[:units_locked] ? params[:units_locked] : 'F'
    @option_flag = params[:option_flag] ? params[:option_flag] : 'N'
    @alias = params[:alias] ? params[:alias] : []
    @fields = params[:fields] ? params[:fields] : []
    @draws = params[:draws] ? params[:draws] : []          
  end
  #TODO implement raise exception
end

Instance Attribute Details

#aliasObject

Returns the value of attribute alias.



128
129
130
# File 'lib/kut/library/components.rb', line 128

def alias
  @alias
end

#draw_pinnameObject

Returns the value of attribute draw_pinname.



126
127
128
# File 'lib/kut/library/components.rb', line 126

def draw_pinname
  @draw_pinname
end

#draw_pinnumberObject

Returns the value of attribute draw_pinnumber.



126
127
128
# File 'lib/kut/library/components.rb', line 126

def draw_pinnumber
  @draw_pinnumber
end

#drawsObject

Returns the value of attribute draws.



128
129
130
# File 'lib/kut/library/components.rb', line 128

def draws
  @draws
end

#fieldsObject

Returns the value of attribute fields.



128
129
130
# File 'lib/kut/library/components.rb', line 128

def fields
  @fields
end

#nameObject

Returns the value of attribute name.



126
127
128
# File 'lib/kut/library/components.rb', line 126

def name
  @name
end

#option_flagObject

Returns the value of attribute option_flag.



127
128
129
# File 'lib/kut/library/components.rb', line 127

def option_flag
  @option_flag
end

#referenceObject

Returns the value of attribute reference.



126
127
128
# File 'lib/kut/library/components.rb', line 126

def reference
  @reference
end

#text_offsetObject

Returns the value of attribute text_offset.



126
127
128
# File 'lib/kut/library/components.rb', line 126

def text_offset
  @text_offset
end

#unit_countObject

Returns the value of attribute unit_count.



127
128
129
# File 'lib/kut/library/components.rb', line 127

def unit_count
  @unit_count
end

#units_lockedObject

Returns the value of attribute units_locked.



127
128
129
# File 'lib/kut/library/components.rb', line 127

def units_locked
  @units_locked
end

Instance Method Details

#to_sObject



147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
# File 'lib/kut/library/components.rb', line 147

def to_s
  result = "DEF #{@name} #{@reference} 0 #{@text_offset} #{@draw_pinnumber} #{@draw_pinname} #{@unit_count} #{@units_locked} #{@option_flag}\n"
  result += "ALIAS"
  @alias.each { |nm| result += " #{nm}" } if @alias
  result += "\n"
  
  @fields.each { |field| result += "#{field.to_s}" } if @fields
  
  result += "DRAW\n"
  
  @draws.each { |draw| result += "#{draw.to_s}" } if @draws
  
  result += "ENDDRAW\n"
  
  result += "ENDDEF\n"
end