Class: Libis::Metadata::FixField

Inherits:
Object
  • Object
show all
Defined in:
lib/libis/metadata/fix_field.rb

Overview

Helper class for implementing a fixed field for MARC

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(tag, datas) ⇒ FixField

Create new fixed field

Parameters:

  • tag (String)

    tag

  • datas (String)

    field data



15
16
17
18
# File 'lib/libis/metadata/fix_field.rb', line 15

def initialize(tag, datas)
  @tag = tag
  @datas = datas || ''
end

Instance Attribute Details

#datasObject

Returns the value of attribute datas.



10
11
12
# File 'lib/libis/metadata/fix_field.rb', line 10

def datas
  @datas
end

#tagObject (readonly)

Returns the value of attribute tag.



9
10
11
# File 'lib/libis/metadata/fix_field.rb', line 9

def tag
  @tag
end

Instance Method Details

#[](from = nil, to = nil) ⇒ Object



21
22
23
24
# File 'lib/libis/metadata/fix_field.rb', line 21

def [](from = nil, to = nil)
  return @datas unless from
  to ? @datas[from..to] : @datas[from]
end

#dumpObject



26
27
28
# File 'lib/libis/metadata/fix_field.rb', line 26

def dump
  "#{@tag}:'#{@datas}'\n"
end