Module: GoogleAnalyticsFeeds::Naming
- Included in:
- DataFeed, FilterBuilder, RowParser
- Defined in:
- lib/google_analytics_feeds.rb
Instance Method Summary collapse
-
#name_to_symbol(name) ⇒ Object
Returns a ruby-friendly symbol from a google analytics name.
-
#symbol_to_name(sym) ⇒ Object
Returns a google analytics name from a ruby symbol.
Instance Method Details
#name_to_symbol(name) ⇒ Object
Returns a ruby-friendly symbol from a google analytics name.
For example:
name_to_symbol("ga:visitorType") # => :visitor_type
66 67 68 |
# File 'lib/google_analytics_feeds.rb', line 66 def name_to_symbol(name) name.sub(/^ga\:/,'').gsub(/(.)([A-Z])/,'\1_\2').downcase.to_sym end |
#symbol_to_name(sym) ⇒ Object
Returns a google analytics name from a ruby symbol.
For example:
symbol_to_name(:visitor_type) # => "ga:visitorType"
75 76 77 78 79 |
# File 'lib/google_analytics_feeds.rb', line 75 def symbol_to_name(sym) parts = sym.to_s.split("_").map(&:capitalize) parts[0].downcase! "ga:" + parts.join('') end |