Class: Weskit::WML::Attribute

Inherits:
Item show all
Defined in:
lib/weskit/wml/attribute.rb

Instance Attribute Summary collapse

Attributes inherited from Item

#name

Instance Method Summary collapse

Methods inherited from Item

#<=>, #formatter=, identifier, #merge, #to_s

Methods included from Mixins::Validator

raise_if_invalid, raise_if_missing, raise_unless

Constructor Details

#initialize(name, value, defaults = {}) ⇒ Attribute

Returns a new instance of Attribute.



31
32
33
34
35
36
37
38
# File 'lib/weskit/wml/attribute.rb', line 31

def initialize name, value, defaults = {}
  @code = @translatable = false

  self.name  = name
  self.value = value

  merge defaults
end

Instance Attribute Details

#valueObject

Returns the value of attribute value.



5
6
7
# File 'lib/weskit/wml/attribute.rb', line 5

def value
  @value
end

Instance Method Details

#code=(bool) ⇒ Object



7
8
9
# File 'lib/weskit/wml/attribute.rb', line 7

def code= bool
  @code = bool ? (@translatable = false ; true) : false
end

#code?Boolean

Returns:

  • (Boolean)


11
12
13
# File 'lib/weskit/wml/attribute.rb', line 11

def code?
  @code
end

#multiline?Boolean

Returns:

  • (Boolean)


15
16
17
# File 'lib/weskit/wml/attribute.rb', line 15

def multiline?
  "#{value}".include? "\n"
end

#text?Boolean

Returns:

  • (Boolean)


19
20
21
# File 'lib/weskit/wml/attribute.rb', line 19

def text?
  code? or multiline? or translatable?
end

#translatable=(bool) ⇒ Object



23
24
25
# File 'lib/weskit/wml/attribute.rb', line 23

def translatable= bool
  @translatable = bool ? (@code = false ; true) : false
end

#translatable?Boolean

Returns:

  • (Boolean)


27
28
29
# File 'lib/weskit/wml/attribute.rb', line 27

def translatable?
  @translatable
end