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



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

def count
  @count
end

#expObject

Returns the value of attribute exp

Returns:

  • (Object)

    the current value of exp



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

def exp
  @exp
end

#lengthObject

Returns the value of attribute length

Returns:

  • (Object)

    the current value of length



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

def length
  @length
end

#precObject

Returns the value of attribute prec

Returns:

  • (Object)

    the current value of prec



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

def prec
  @prec
end

Instance Method Details

#count_argsObject



564
565
566
# File 'ext/fortio/lib/fortio/fortran_format.rb', line 564

def count_args
  return count
end

#inspectObject



567
568
569
570
571
# File 'ext/fortio/lib/fortio/fortran_format.rb', line 567

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



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

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



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

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