Class: Gooby::DelimLine

Inherits:
GoobyObject show all
Defined in:
lib/gooby/cls_delim_line.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from GoobyProjectInfo

#google_maps_api_level, #project_author, #project_copyright, #project_date, #project_license, #project_version_number, #project_year, #some_new_thing, #tested_files

Methods included from Introspect

#introspect, #to_yaml_properties

Methods included from GoobyString

#tokenize

Methods included from GoobyIO

#read_as_ascii_lines, #read_lines, #strip_lines

Constructor Details

#initialize(line, trim = true, delim = default_delimiter) ⇒ DelimLine

Returns a new instance of DelimLine.



16
17
18
19
20
21
22
23
24
# File 'lib/gooby/cls_delim_line.rb', line 16

def initialize(line, trim=true, delim=default_delimiter)
  @line  = line
  @trim  = trim
  @delim = delim
  @tokens = @line.split(@delim)  
  if trim
    @tokens.each { | token | token.strip! }
  end
end

Instance Attribute Details

#delimObject (readonly)

Returns the value of attribute delim.



14
15
16
# File 'lib/gooby/cls_delim_line.rb', line 14

def delim
  @delim
end

#lineObject (readonly)

Returns the value of attribute line.



14
15
16
# File 'lib/gooby/cls_delim_line.rb', line 14

def line
  @line
end

#tokensObject (readonly)

Returns the value of attribute tokens.



14
15
16
# File 'lib/gooby/cls_delim_line.rb', line 14

def tokens
  @tokens
end

#trimObject (readonly)

Returns the value of attribute trim.



14
15
16
# File 'lib/gooby/cls_delim_line.rb', line 14

def trim
  @trim
end

Instance Method Details

#as_trackpoint(num_idx, lat_idx, lng_idx, alt_idx, dttm_idx) ⇒ Object



26
27
28
# File 'lib/gooby/cls_delim_line.rb', line 26

def as_trackpoint(num_idx, lat_idx, lng_idx, alt_idx, dttm_idx)
  Trackpoint.new(@tokens[num_idx], @tokens[lat_idx], @tokens[lng_idx], @tokens[alt_idx], @tokens[dttm_idx])
end

#is_comment?Boolean

Returns:

  • (Boolean)


30
31
32
# File 'lib/gooby/cls_delim_line.rb', line 30

def is_comment?
  @line.strip.match('^#') ? true : false
end

#to_sObject



34
35
36
# File 'lib/gooby/cls_delim_line.rb', line 34

def to_s
  "DelimLine: length: #{@line.size} trim: #{@trim} delim: #{@delim} tokens: #{@tokens.size}"
end