Class: Rubymine2Xcode::RubymineTheme
- Inherits:
-
Object
- Object
- Rubymine2Xcode::RubymineTheme
- Includes:
- REXML
- Defined in:
- lib/rubymine2xcode-theme/rubymine.rb
Instance Attribute Summary collapse
-
#attributes ⇒ Object
Returns the value of attribute attributes.
-
#colours ⇒ Object
Returns the value of attribute colours.
-
#font_name ⇒ Object
Returns the value of attribute font_name.
-
#font_size ⇒ Object
Returns the value of attribute font_size.
Class Method Summary collapse
Instance Method Summary collapse
- #colour_named(name) ⇒ Object
-
#initialize ⇒ RubymineTheme
constructor
A new instance of RubymineTheme.
Constructor Details
#initialize ⇒ RubymineTheme
Returns a new instance of RubymineTheme.
14 15 16 17 |
# File 'lib/rubymine2xcode-theme/rubymine.rb', line 14 def initialize() @colours = [] @attributes = {} end |
Instance Attribute Details
#attributes ⇒ Object
Returns the value of attribute attributes.
11 12 13 |
# File 'lib/rubymine2xcode-theme/rubymine.rb', line 11 def attributes @attributes end |
#colours ⇒ Object
Returns the value of attribute colours.
10 11 12 |
# File 'lib/rubymine2xcode-theme/rubymine.rb', line 10 def colours @colours end |
#font_name ⇒ Object
Returns the value of attribute font_name.
12 13 14 |
# File 'lib/rubymine2xcode-theme/rubymine.rb', line 12 def font_name @font_name end |
#font_size ⇒ Object
Returns the value of attribute font_size.
12 13 14 |
# File 'lib/rubymine2xcode-theme/rubymine.rb', line 12 def font_size @font_size end |
Class Method Details
.load_file(filename) ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/rubymine2xcode-theme/rubymine.rb', line 24 def self.load_file(filename) instance = self.new xmlfile = File.new(filename) xmldoc = Document.new(xmlfile) # Now get the root element root = xmldoc.root # set colours root.elements.each("colors/option") do |element| name = element.attributes["name"] value = element.attributes["value"] instance.colours << { :name => name, :value => value } end # read attributes root.elements.each("attributes/option") do |element| name = element.attributes["name"] attr = {} element.elements.each("value/option") do |value_element| value_name = value_element.attributes["name"] value_value = value_element.attributes["value"] attr[value_name] = value_value end instance.attributes[name] = attr end # read font name and size instance.font_name = XPath.first(xmldoc, '/scheme/option[@name="EDITOR_FONT_NAME"]').attribute("value").value instance.font_size = XPath.first(xmldoc, '/scheme/option[@name="EDITOR_FONT_SIZE"]').attribute("value").value.to_i instance end |
Instance Method Details
#colour_named(name) ⇒ Object
19 20 21 22 |
# File 'lib/rubymine2xcode-theme/rubymine.rb', line 19 def colour_named(name) result = @colours.find { |colour| colour[:name] == name } result[:value] unless result.nil? end |