Class: MarcBot::FieldBuilder
- Inherits:
-
Object
- Object
- MarcBot::FieldBuilder
- Defined in:
- lib/marc_bot/field_builder.rb
Constant Summary collapse
- SKIP_KEYS =
%i[ indicator1 indicator2 ]
Instance Attribute Summary collapse
-
#input ⇒ Object
readonly
Returns the value of attribute input.
-
#method ⇒ Object
readonly
Returns the value of attribute method.
Class Method Summary collapse
Instance Method Summary collapse
- #fields ⇒ MARC::ControlField, MARC::DataField
-
#initialize(method, input, options) ⇒ FieldBuilder
constructor
A new instance of FieldBuilder.
Constructor Details
#initialize(method, input, options) ⇒ FieldBuilder
Returns a new instance of FieldBuilder.
14 15 16 17 |
# File 'lib/marc_bot/field_builder.rb', line 14 def initialize(method, input, ) @method = method @input = input end |
Instance Attribute Details
#input ⇒ Object (readonly)
Returns the value of attribute input.
12 13 14 |
# File 'lib/marc_bot/field_builder.rb', line 12 def input @input end |
#method ⇒ Object (readonly)
Returns the value of attribute method.
12 13 14 |
# File 'lib/marc_bot/field_builder.rb', line 12 def method @method end |
Class Method Details
.call(**args) ⇒ Object
8 9 10 |
# File 'lib/marc_bot/field_builder.rb', line 8 def self.call(**args) new(args.delete(:method), args.delete(:input), args).fields end |
Instance Method Details
#fields ⇒ MARC::ControlField, MARC::DataField
20 21 22 23 24 25 26 27 28 |
# File 'lib/marc_bot/field_builder.rb', line 20 def fields if input.is_a?(String) data_or_control_field(input) elsif input.is_a?(Hash) MARC::DataField.new(tag, indicator1, indicator2, *subfield_array) else raise ArgumentError, "#{input.class} isn't a supported factory type" end end |