Module: Weechat::Properties::ClassMethods

Included in:
Weechat::Properties
Defined in:
lib/weechat/properties.rb

Instance Method Summary collapse

Instance Method Details

#allObject



39
40
41
42
43
44
45
# File 'lib/weechat/properties.rb', line 39

def all
  items = []
  Weechat::Infolist.parse(@type).each do |item|
    items << from_ptr(item[:pointer])
  end
  items
end

#apply_rtransformation(property, value) ⇒ Object



89
90
91
# File 'lib/weechat/properties.rb', line 89

def apply_rtransformation(property, value)
  Utilities.apply_transformation(property, value, @rtransformations)
end

#apply_transformation(property, value) ⇒ Object



85
86
87
# File 'lib/weechat/properties.rb', line 85

def apply_transformation(property, value)
  Utilities.apply_transformation(property, value, @transformations)
end

#init_propertiesObject



47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
# File 'lib/weechat/properties.rb', line 47

def init_properties
  @known_string_properties  ||= [].freeze
  @known_integer_properties ||= [].freeze
  @settable_properties      ||= [].freeze
  @transformations          ||= {}.freeze
  @rtransformations         ||= {}.freeze
  @mappings                 ||= {}.freeze

  @type = self.name.downcase.split("::").last

  # this defines all the getter methods
  known_properties.each do |property|
    define_method(property) { get_property(property) }
  end

  # this defined all the setter methods
  @settable_properties.each do |property|
    define_method(property + '=') {|v| set_property(property, v, true) }
  end

  # this adds a few aliases to make interfaces more rubyish
  @mappings.each do |key, value|
    if respond_to?(value)
      # it is a string/integer property
      alias_method key, value
    else
      # it is an infolist property
      define_method(key) do |*args|
        __send__(value, *args)
      end
    end

  end

  InstanceMethods.alias_methods(@type)
  include InstanceMethods
end

#known_integer_propertiesObject



11
12
13
# File 'lib/weechat/properties.rb', line 11

def known_integer_properties
  @known_integer_properties
end

#known_propertiesArray<Symbol>

Returns all known properties.

Returns:

  • (Array<Symbol>)

    The properties



7
8
9
# File 'lib/weechat/properties.rb', line 7

def known_properties
  @known_integer_properties + @known_string_properties
end

#known_string_propertiesObject



15
16
17
# File 'lib/weechat/properties.rb', line 15

def known_string_properties
  @known_string_properties
end

#mappingsObject



31
32
33
# File 'lib/weechat/properties.rb', line 31

def mappings
  @mappings
end

#rtransformationsObject



27
28
29
# File 'lib/weechat/properties.rb', line 27

def rtransformations
  @rtransformations
end

#settable_propertiesObject



19
20
21
# File 'lib/weechat/properties.rb', line 19

def settable_properties
  @settable_properties
end

#transformationsObject



23
24
25
# File 'lib/weechat/properties.rb', line 23

def transformations
  @transformations
end

#typeObject



35
36
37
# File 'lib/weechat/properties.rb', line 35

def type
  @type
end