Skip to content

Instantly share code, notes, and snippets.

@kotp
Last active December 12, 2015 12:29
Show Gist options
  • Select an option

  • Save kotp/4772181 to your computer and use it in GitHub Desktop.

Select an option

Save kotp/4772181 to your computer and use it in GitHub Desktop.

Revisions

  1. kotp revised this gist Feb 12, 2013. 2 changed files with 2 additions and 1 deletion.
    2 changes: 1 addition & 1 deletion global_var.rb
    Original file line number Diff line number Diff line change
    @@ -7,6 +7,6 @@ module SharedVar

    def your_method
    "Whatever your method would be."

    end
    end

    1 change: 1 addition & 0 deletions other_file.rb
    Original file line number Diff line number Diff line change
    @@ -6,3 +6,4 @@
    puts $GlobalConstant_WithDollarSign
    puts SharedVar::NAMESPACED_CONSTANT
    puts SharedVar::your_method

  2. kotp revised this gist Feb 12, 2013. 1 changed file with 7 additions and 7 deletions.
    14 changes: 7 additions & 7 deletions global_var.rb
    Original file line number Diff line number Diff line change
    @@ -2,11 +2,11 @@

    GlobalConstant = 'GlobalConstant'
    $GlobalConstant_WithDollarSign = 'Global Constant with Dollar Sign'
    module SharedVar
    module SharedVar
    NAMESPACED_CONSTANT = 'Named spaced constant'
    def your_method
    "Whatever your method would be."
    end
    end

    def your_method
    "Whatever your method would be."

    end
    end
  3. kotp created this gist Feb 12, 2013.
    12 changes: 12 additions & 0 deletions global_var.rb
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,12 @@
    puts "Loading global_var.rb"

    GlobalConstant = 'GlobalConstant'
    $GlobalConstant_WithDollarSign = 'Global Constant with Dollar Sign'
    module SharedVar
    NAMESPACED_CONSTANT = 'Named spaced constant'

    def your_method
    "Whatever your method would be."

    end
    end
    8 changes: 8 additions & 0 deletions other_file.rb
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,8 @@
    require './global_var'

    include SharedVar

    puts GlobalConstant
    puts $GlobalConstant_WithDollarSign
    puts SharedVar::NAMESPACED_CONSTANT
    puts SharedVar::your_method