Module: OpenHAB::Core::Items::Semantics::TagClassMethods

Defined in:
lib/openhab/core/items/semantics/tag_class_methods.rb

Overview

Adds tag attributes to the semantic tag class

Instance Method Summary collapse

Instance Method Details

#description(locale = nil) ⇒ String

Returns the tag's description

Parameters:

  • locale (java.util.Locale) (defaults to: nil)

    The locale that the description should be in, if available. When nil, the system's default locale is used.

Returns:

  • (String)

    The tag's description



62
63
64
65
66
67
68
# File 'lib/openhab/core/items/semantics/tag_class_methods.rb', line 62

def description(locale = nil)
  unless SemanticTags.respond_to?(:get_description)
    return java_class.get_annotation(org.openhab.core.semantics.TagInfo.java_class).description
  end

  SemanticTags.get_description(java_class, locale || java.util.Locale.default)
end

#label(locale = nil) ⇒ String

Returns the tag's label

Parameters:

  • locale (java.util.Locale) (defaults to: nil)

    The locale that the label should be in, if available. When nil, the system's default locale is used.

Returns:

  • (String)

    The tag's label



33
34
35
# File 'lib/openhab/core/items/semantics/tag_class_methods.rb', line 33

def label(locale = nil)
  SemanticTags.get_label(java_class, locale || java.util.Locale.default)
end

#synonyms(locale = nil) ⇒ Array<String>

Returns the tag's synonyms

Parameters:

  • locale (java.util.Locale) (defaults to: nil)

    The locale that the label should be in, if available. When nil, the system's default locale is used.

Returns:

  • (Array<String>)

    The list of synonyms in the requested locale.



45
46
47
48
49
50
51
52
# File 'lib/openhab/core/items/semantics/tag_class_methods.rb', line 45

def synonyms(locale = nil)
  unless SemanticTags.respond_to?(:get_synonyms)
    return java_class.get_annotation(org.openhab.core.semantics.TagInfo.java_class).synonyms
                     .split(",").map(&:strip)
  end

  SemanticTags.get_synonyms(java_class, locale || java.util.Locale.default).to_a
end

#to_sString

Returns the tag's string representation

Returns:

  • (String)


21
22
23
# File 'lib/openhab/core/items/semantics/tag_class_methods.rb', line 21

def to_s
  java_class.simple_name
end