Class: Uinit::Structure::Attribute

Inherits:
Object
  • Object
show all
Defined in:
lib/uinit/structure/attribute.rb

Overview

rubocop:disable Metrics/ClassLength

Constant Summary collapse

NAME_REGEX =
/\A[A-Za-z]\w*\z/
UNDEFINED =
Class.new.new.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeAttribute

Returns a new instance of Attribute.



10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/uinit/structure/attribute.rb', line 10

def initialize
  @private_get = false
  @private_set = false
  @name = nil
  @type = nil
  @default = UNDEFINED
  @struct = nil
  @array_struct = false
  @init = true
  @get = nil
  @set = nil
  @as_json = true
  @aliases = []
end

Instance Attribute Details

#aliasesObject

Returns the value of attribute aliases.



26
27
28
# File 'lib/uinit/structure/attribute.rb', line 26

def aliases
  @aliases
end

#array_structObject

Returns the value of attribute array_struct.



26
27
28
# File 'lib/uinit/structure/attribute.rb', line 26

def array_struct
  @array_struct
end

#as_jsonObject

Returns the value of attribute as_json.



26
27
28
# File 'lib/uinit/structure/attribute.rb', line 26

def as_json
  @as_json
end

#defaultObject

Returns the value of attribute default.



25
26
27
# File 'lib/uinit/structure/attribute.rb', line 25

def default
  @default
end

#getObject

Returns the value of attribute get.



26
27
28
# File 'lib/uinit/structure/attribute.rb', line 26

def get
  @get
end

#initObject

Returns the value of attribute init.



26
27
28
# File 'lib/uinit/structure/attribute.rb', line 26

def init
  @init
end

#nameObject

Returns the value of attribute name.



26
27
28
# File 'lib/uinit/structure/attribute.rb', line 26

def name
  @name
end

#optional=(value) ⇒ Object (writeonly)

Sets the attribute optional

Parameters:

  • value

    the value to set the attribute optional to.



97
98
99
# File 'lib/uinit/structure/attribute.rb', line 97

def optional=(value)
  @optional = value
end

#private_getObject

Returns the value of attribute private_get.



26
27
28
# File 'lib/uinit/structure/attribute.rb', line 26

def private_get
  @private_get
end

#private_setObject

Returns the value of attribute private_set.



26
27
28
# File 'lib/uinit/structure/attribute.rb', line 26

def private_set
  @private_set
end

#setObject

Returns the value of attribute set.



26
27
28
# File 'lib/uinit/structure/attribute.rb', line 26

def set
  @set
end

#structObject

Returns the value of attribute struct.



26
27
28
# File 'lib/uinit/structure/attribute.rb', line 26

def struct
  @struct
end

#typeObject

Returns the value of attribute type.



26
27
28
# File 'lib/uinit/structure/attribute.rb', line 26

def type
  @type
end

Instance Method Details

#as_json?Boolean

Returns:

  • (Boolean)


140
141
142
# File 'lib/uinit/structure/attribute.rb', line 140

def as_json?
  @as_json != false
end

#optional?Boolean

Returns:

  • (Boolean)


93
94
95
# File 'lib/uinit/structure/attribute.rb', line 93

def optional?
  defined?(@optional) ? @optional : @default != UNDEFINED
end