Class: Gtk::Builder

Inherits:
Object
  • Object
show all
Defined in:
lib/gtk3/builder.rb

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Builder

Returns a new instance of Builder.



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/gtk3/builder.rb', line 20

def initialize(options={})
  file      = options[:file]
  resource  = options[:resource]
  string    = options[:string]

  if file
    initialize_new_from_file(file)
  elsif resource
    initialize_new_from_resource(resource)
  elsif string
    initialize_new_from_string(string, string.bytesize)
  else
    initialize_raw
  end
end

Instance Method Details

#<<(target) ⇒ Object



55
56
57
58
# File 'lib/gtk3/builder.rb', line 55

def <<(target)
  add(target)
  self
end

#add(target) ⇒ Object



43
44
45
46
47
48
49
50
51
52
53
# File 'lib/gtk3/builder.rb', line 43

def add(target)
  if target.respond_to?(:to_path)
    add_from_file(target.to_path)
  elsif target.start_with?("<") or target.start_with?(" ")
    add_from_string(target)
  elsif File.exist?(target)
    add_from_file(target)
  else
    add_from_resource(target)
  end
end

#add_from_string(string) ⇒ Object



39
40
41
# File 'lib/gtk3/builder.rb', line 39

def add_from_string(string)
  add_from_string_raw(string, string.bytesize)
end

#add_from_string_rawObject



38
# File 'lib/gtk3/builder.rb', line 38

alias_method :add_from_string_raw, :add_from_string

#initialize_rawObject



19
# File 'lib/gtk3/builder.rb', line 19

alias_method :initialize_raw, :initialize