Class: Rawk::Record

Inherits:
String
  • Object
show all
Defined in:
lib/rawk/rawk.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(str, fs, eor = "\n") ⇒ Record

Returns a new instance of Record.



88
89
90
91
# File 'lib/rawk/rawk.rb', line 88

def initialize(str, fs, eor = "\n")
  self.replace(str.chomp(eor))
  @fs = fs
end

Class Method Details

.column_postion_accessor(name, position) ⇒ Object



82
83
84
85
86
# File 'lib/rawk/rawk.rb', line 82

def self.column_postion_accessor(name, position)
  define_method(name.to_sym) do
    cols[position]
  end
end

Instance Method Details

#colsObject Also known as: c



93
94
95
# File 'lib/rawk/rawk.rb', line 93

def cols
  split(@fs)
end

#nfObject



98
99
100
# File 'lib/rawk/rawk.rb', line 98

def nf 
  cols.length
end