Class: FortranFormatParser::NodeE
- Inherits:
-
Struct
- Object
- Struct
- FortranFormatParser::NodeE
- Defined in:
- ext/fortio/lib/fortio/fortran_format.rb,
ext/fortio/lib/fortio/fortran_format.rb
Instance Attribute Summary collapse
-
#count ⇒ Object
Returns the value of attribute count.
-
#exp ⇒ Object
Returns the value of attribute exp.
-
#length ⇒ Object
Returns the value of attribute length.
-
#prec ⇒ Object
Returns the value of attribute prec.
Instance Method Summary collapse
- #count_args ⇒ Object
- #inspect ⇒ Object
- #read(io, list, state) ⇒ Object
- #write(io, list, state) ⇒ Object
Instance Attribute Details
#count ⇒ Object
Returns the value of attribute count
514 515 516 |
# File 'ext/fortio/lib/fortio/fortran_format.rb', line 514 def count @count end |
#exp ⇒ Object
Returns the value of attribute exp
514 515 516 |
# File 'ext/fortio/lib/fortio/fortran_format.rb', line 514 def exp @exp end |
#length ⇒ Object
Returns the value of attribute length
514 515 516 |
# File 'ext/fortio/lib/fortio/fortran_format.rb', line 514 def length @length end |
#prec ⇒ Object
Returns the value of attribute prec
514 515 516 |
# File 'ext/fortio/lib/fortio/fortran_format.rb', line 514 def prec @prec end |
Instance Method Details
#count_args ⇒ Object
534 535 536 |
# File 'ext/fortio/lib/fortio/fortran_format.rb', line 534 def count_args return count end |
#inspect ⇒ Object
537 538 539 540 541 |
# File 'ext/fortio/lib/fortio/fortran_format.rb', line 537 def inspect count_str = count == 1 ? "" : count.to_s exp_str = (exp.nil? or exp == 2) ? "" : "E#{exp}" return "#{count_str}E#{length}.#{prec}#{exp_str}" end |
#read(io, list, state) ⇒ Object
522 523 524 525 526 527 528 529 530 531 532 533 |
# File 'ext/fortio/lib/fortio/fortran_format.rb', line 522 def read (io, list, state) str = nil count.times do str = io.read(length) if state.zero str = str.gsub(/ /,'0') end list << str.to_f end rescue raise "reading error in fortran format : #{str.dump} for #{self.inspect}" end |
#write(io, list, state) ⇒ Object
516 517 518 519 520 521 |
# File 'ext/fortio/lib/fortio/fortran_format.rb', line 516 def write (io, list, state) count.times do str = FortranFormat.write_E(state.sign, state.scale, length, prec, exp, list.shift) io << FortranFormat.check_length(length, str) end end |