Class: TopasInput
- Inherits:
-
Object
- Object
- TopasInput
- Defined in:
- lib/topas-tools/TopasInput.rb
Instance Attribute Summary collapse
-
#base_name ⇒ Object
readonly
Returns the value of attribute base_name.
-
#k1 ⇒ Object
readonly
Returns the value of attribute k1.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#r_wp ⇒ Object
readonly
Returns the value of attribute r_wp.
-
#restrains ⇒ Object
readonly
Returns the value of attribute restrains.
-
#text ⇒ Object
readonly
Returns the value of attribute text.
Instance Method Summary collapse
-
#initialize(text, base_name = nil) ⇒ TopasInput
constructor
A new instance of TopasInput.
- #restrain_names ⇒ Object
- #set_k1(num) ⇒ Object
- #set_k1!(num) ⇒ Object
- #set_restrain(name, new) ⇒ Object
- #set_restrain!(name, new) ⇒ Object
Constructor Details
#initialize(text, base_name = nil) ⇒ TopasInput
Returns a new instance of TopasInput.
2 3 4 5 6 7 8 9 |
# File 'lib/topas-tools/TopasInput.rb', line 2 def initialize text, base_name = nil @text = text.dup @k1 = get_k1 @base_name = get_base_name base_name @name = get_name @restrains = get_restrains @r_wp = get_rwp end |
Instance Attribute Details
#base_name ⇒ Object (readonly)
Returns the value of attribute base_name.
11 12 13 |
# File 'lib/topas-tools/TopasInput.rb', line 11 def base_name @base_name end |
#k1 ⇒ Object (readonly)
Returns the value of attribute k1.
11 12 13 |
# File 'lib/topas-tools/TopasInput.rb', line 11 def k1 @k1 end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
11 12 13 |
# File 'lib/topas-tools/TopasInput.rb', line 11 def name @name end |
#r_wp ⇒ Object (readonly)
Returns the value of attribute r_wp.
11 12 13 |
# File 'lib/topas-tools/TopasInput.rb', line 11 def r_wp @r_wp end |
#restrains ⇒ Object (readonly)
Returns the value of attribute restrains.
11 12 13 |
# File 'lib/topas-tools/TopasInput.rb', line 11 def restrains @restrains end |
#text ⇒ Object (readonly)
Returns the value of attribute text.
11 12 13 |
# File 'lib/topas-tools/TopasInput.rb', line 11 def text @text end |
Instance Method Details
#restrain_names ⇒ Object
26 27 28 |
# File 'lib/topas-tools/TopasInput.rb', line 26 def restrain_names @restrains.map{|r| r[:name]} end |
#set_k1(num) ⇒ Object
22 23 24 |
# File 'lib/topas-tools/TopasInput.rb', line 22 def set_k1(num) dup.set_k1!(num) end |
#set_k1!(num) ⇒ Object
14 15 16 17 18 19 20 |
# File 'lib/topas-tools/TopasInput.rb', line 14 def set_k1!(num) @k1 = num.to_f @text = @text.sub(/(penalties_weighting_K1\s+)[\d.]+/ , "\\1#{@k1}"). sub(/[\d.]*(\.cif)/ , "#{@k1}\\1") @name = get_name self end |
#set_restrain(name, new) ⇒ Object
40 41 42 |
# File 'lib/topas-tools/TopasInput.rb', line 40 def set_restrain(name, new) dup.set_restrain!(name, new) end |
#set_restrain!(name, new) ⇒ Object
30 31 32 33 34 35 36 37 38 |
# File 'lib/topas-tools/TopasInput.rb', line 30 def set_restrain!(name, new) if r = @restrains.select{|r| r[:name] == name}[0] r[:restrain] = new @text = write_restrains self else raise "No restrain with the name #{name}" end end |