Class: Sam::Header::Record
- Inherits:
-
Object
- Object
- Sam::Header::Record
- Defined in:
- lib/sam.rb
Instance Attribute Summary collapse
-
#comment ⇒ Object
readonly
Returns the value of attribute comment.
-
#line ⇒ Object
readonly
Returns the value of attribute line.
-
#tags ⇒ Object
readonly
Returns the value of attribute tags.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
-
#initialize(line) ⇒ Record
constructor
A new instance of Record.
- #to_s ⇒ Object
Constructor Details
#initialize(line) ⇒ Record
Returns a new instance of Record.
14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/sam.rb', line 14 def initialize line @line = line if line =~ /^@CO\t(.*)/ @type = :CO @comment = $1 end line.match /^@([A-Za-z][A-Za-z])\t((?:[A-Za-z][A-Za-z0-9]:[ -~]+(?:\t|$))+)/ do |m| @type = m[1].to_sym @tags = Hash[m[2].split(/\t/).map{|s| s.split(/:/)}] end end |
Instance Attribute Details
#comment ⇒ Object (readonly)
Returns the value of attribute comment.
11 12 13 |
# File 'lib/sam.rb', line 11 def comment @comment end |
#line ⇒ Object (readonly)
Returns the value of attribute line.
12 13 14 |
# File 'lib/sam.rb', line 12 def line @line end |
#tags ⇒ Object (readonly)
Returns the value of attribute tags.
10 11 12 |
# File 'lib/sam.rb', line 10 def @tags end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
9 10 11 |
# File 'lib/sam.rb', line 9 def type @type end |
Instance Method Details
#to_s ⇒ Object
26 27 28 29 30 31 32 |
# File 'lib/sam.rb', line 26 def to_s if @type == :CO "@#{@type}\t#{@comment}" else "@#{@type}\t#{.map{ |t,v| "#{t}:#{v}" }.join("\t")}" end end |