Class: Kut::Library::Component
- Inherits:
-
Object
- Object
- Kut::Library::Component
- Defined in:
- lib/kut/library/components.rb
Instance Attribute Summary collapse
-
#alias ⇒ Object
Returns the value of attribute alias.
-
#draw_pinname ⇒ Object
Returns the value of attribute draw_pinname.
-
#draw_pinnumber ⇒ Object
Returns the value of attribute draw_pinnumber.
-
#draws ⇒ Object
Returns the value of attribute draws.
-
#fields ⇒ Object
Returns the value of attribute fields.
-
#name ⇒ Object
Returns the value of attribute name.
-
#option_flag ⇒ Object
Returns the value of attribute option_flag.
-
#reference ⇒ Object
Returns the value of attribute reference.
-
#text_offset ⇒ Object
Returns the value of attribute text_offset.
-
#unit_count ⇒ Object
Returns the value of attribute unit_count.
-
#units_locked ⇒ Object
Returns the value of attribute units_locked.
Instance Method Summary collapse
-
#initialize(params = {}) ⇒ Component
constructor
A new instance of Component.
- #to_s ⇒ Object
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
#alias ⇒ Object
Returns the value of attribute alias.
128 129 130 |
# File 'lib/kut/library/components.rb', line 128 def alias @alias end |
#draw_pinname ⇒ Object
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_pinnumber ⇒ Object
Returns the value of attribute draw_pinnumber.
126 127 128 |
# File 'lib/kut/library/components.rb', line 126 def draw_pinnumber @draw_pinnumber end |
#draws ⇒ Object
Returns the value of attribute draws.
128 129 130 |
# File 'lib/kut/library/components.rb', line 128 def draws @draws end |
#fields ⇒ Object
Returns the value of attribute fields.
128 129 130 |
# File 'lib/kut/library/components.rb', line 128 def fields @fields end |
#name ⇒ Object
Returns the value of attribute name.
126 127 128 |
# File 'lib/kut/library/components.rb', line 126 def name @name end |
#option_flag ⇒ Object
Returns the value of attribute option_flag.
127 128 129 |
# File 'lib/kut/library/components.rb', line 127 def option_flag @option_flag end |
#reference ⇒ Object
Returns the value of attribute reference.
126 127 128 |
# File 'lib/kut/library/components.rb', line 126 def reference @reference end |
#text_offset ⇒ Object
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_count ⇒ Object
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_locked ⇒ Object
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_s ⇒ Object
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 |