Class: FortranFormatParser::NodeES

Inherits:
Struct
  • Object
show all
Defined in:
ext/fortio/lib/fortio/fortran_format.rb,
ext/fortio/lib/fortio/fortran_format.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#countObject

Returns the value of attribute count

Returns:

  • (Object)

    the current value of count



542
543
544
# File 'ext/fortio/lib/fortio/fortran_format.rb', line 542

def count
  @count
end

#expObject

Returns the value of attribute exp

Returns:

  • (Object)

    the current value of exp



542
543
544
# File 'ext/fortio/lib/fortio/fortran_format.rb', line 542

def exp
  @exp
end

#lengthObject

Returns the value of attribute length

Returns:

  • (Object)

    the current value of length



542
543
544
# File 'ext/fortio/lib/fortio/fortran_format.rb', line 542

def length
  @length
end

#precObject

Returns the value of attribute prec

Returns:

  • (Object)

    the current value of prec



542
543
544
# File 'ext/fortio/lib/fortio/fortran_format.rb', line 542

def prec
  @prec
end

Instance Method Details

#count_argsObject



562
563
564
# File 'ext/fortio/lib/fortio/fortran_format.rb', line 562

def count_args
  return count
end

#inspectObject



565
566
567
568
569
# File 'ext/fortio/lib/fortio/fortran_format.rb', line 565

def inspect
  count_str = count == 1 ? "" : count.to_s
  exp_str   = (exp.nil? or exp == 2) ? "" :  "E#{exp}"
  return "#{count_str}ES#{length}.#{prec}#{exp_str}"
end

#read(io, list, state) ⇒ Object



550
551
552
553
554
555
556
557
558
559
560
561
# File 'ext/fortio/lib/fortio/fortran_format.rb', line 550

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



544
545
546
547
548
549
# File 'ext/fortio/lib/fortio/fortran_format.rb', line 544

def write (io, list, state) 
  count.times do
    str = FortranFormat.write_E(state.sign, 1, length, prec, exp, list.shift)
    io << FortranFormat.check_length(length, str)
  end
end