File: compatibility.rb

package info (click to toggle)
ruby-spreadsheet 1.3.3-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 8,964 kB
  • sloc: ruby: 6,943; makefile: 10
file content (23 lines) | stat: -rw-r--r-- 566 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
module Spreadsheet
  module Compatibility
    ##
    # One of the most incisive changes in terms of meta-programming in Ruby 1.9
    # is the switch from representing instance-variable names as Strings to
    # presenting them as Symbols. ivar_name provides compatibility.
    if RUBY_VERSION >= '1.9'
      def ivar_name symbol
        :"@#{symbol}"
      end
      def method_name symbol
        symbol.to_sym
      end
    else
      def ivar_name symbol
        "@#{symbol}"
      end
      def method_name symbol
        symbol.to_s
      end
    end
  end
end