Class: Gooby::DelimLine
- Inherits:
-
GoobyObject
- Object
- GoobyObject
- Gooby::DelimLine
- Defined in:
- lib/gooby/cls_delim_line.rb
Instance Attribute Summary collapse
-
#delim ⇒ Object
readonly
Returns the value of attribute delim.
-
#line ⇒ Object
readonly
Returns the value of attribute line.
-
#tokens ⇒ Object
readonly
Returns the value of attribute tokens.
-
#trim ⇒ Object
readonly
Returns the value of attribute trim.
Instance Method Summary collapse
- #as_trackpoint(num_idx, lat_idx, lng_idx, alt_idx, dttm_idx) ⇒ Object
-
#initialize(line, trim = true, delim = default_delimiter) ⇒ DelimLine
constructor
A new instance of DelimLine.
- #is_comment? ⇒ Boolean
- #to_s ⇒ Object
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
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
#delim ⇒ Object (readonly)
Returns the value of attribute delim.
14 15 16 |
# File 'lib/gooby/cls_delim_line.rb', line 14 def delim @delim end |
#line ⇒ Object (readonly)
Returns the value of attribute line.
14 15 16 |
# File 'lib/gooby/cls_delim_line.rb', line 14 def line @line end |
#tokens ⇒ Object (readonly)
Returns the value of attribute tokens.
14 15 16 |
# File 'lib/gooby/cls_delim_line.rb', line 14 def tokens @tokens end |
#trim ⇒ Object (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
30 31 32 |
# File 'lib/gooby/cls_delim_line.rb', line 30 def is_comment? @line.strip.match('^#') ? true : false end |
#to_s ⇒ Object
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 |