Sha256: 7a18dcd847b8e4743375e38da2a24147415cb6617051c4651b1b74b8fcf05246

Contents?: true

Size: 684 Bytes

Versions: 5

Compression:

Stored size: 684 Bytes

Contents

module Langusta
  class JavaPropertyReader
    # This is a minimal implementation, don't expect this to actually work.

    def initialize(filename)
      @lines = File.open(filename).readlines
      parse()
    end

    def [](property)
      @properties[property]
    end

    def underlying_hash
      @properties
    end

    private
    def parse
      @properties = {}
      @lines.each do |line|
        prop_name, value = line.split(/\=/)
        @properties[prop_name] = parse_value(value)
      end
    end

    def parse_value(value)
      codepoints = value.scan(/([0-9A-F]{4})/)
      codepoints.map do |cp|
        int_cp = cp.first.to_i(16)
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
langusta-0.2.4 lib/langusta/java_property_reader.rb
langusta-0.2.3 lib/langusta/java_property_reader.rb
langusta-0.2.2 lib/langusta/java_property_reader.rb
langusta-0.2.1 lib/langusta/java_property_reader.rb
langusta-0.2.0 lib/langusta/java_property_reader.rb