Class: Odca::SchemaBase::Attribute

Inherits:
Object
  • Object
show all
Defined in:
lib/odca/schema_base.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name:, type:, pii:) ⇒ Attribute

Returns a new instance of Attribute.



73
74
75
76
77
# File 'lib/odca/schema_base.rb', line 73

def initialize(name:, type:, pii:)
  @name = name
  @type = type
  @pii = pii
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



58
59
60
# File 'lib/odca/schema_base.rb', line 58

def name
  @name
end

#piiObject (readonly)

Returns the value of attribute pii.



58
59
60
# File 'lib/odca/schema_base.rb', line 58

def pii
  @pii
end

#typeObject (readonly)

Returns the value of attribute type.



58
59
60
# File 'lib/odca/schema_base.rb', line 58

def type
  @type
end

Class Method Details

.new(**args) ⇒ Object



60
61
62
63
64
65
66
67
68
69
70
71
# File 'lib/odca/schema_base.rb', line 60

def self.new(**args)
  name = args.fetch(:name).strip
  raise 'Attribute name cannot be empty' if name.empty?
  type = args.fetch(:type).strip
  raise 'Attribute type cannot be empty' if type.empty?

  super(
    name: name,
    type: type,
    pii: args.fetch(:pii).to_s.strip
  )
end

Instance Method Details

#pii?Boolean

Returns:

  • (Boolean)


79
80
81
82
83
84
85
86
87
88
# File 'lib/odca/schema_base.rb', line 79

def pii?
  case pii
  when 'Y'
    true
  when ''
    false
  else
    raise RuntimeError.new("Unrecognized character: #{pii}")
  end
end