Try:
> 'gmail.test.com'.split('.').last(2) == ['test','com']
=> true
More Related Contents:
- How to make a HTTP request using Ruby on Rails?
- cannot load such file — script/rails : Getting this error while remote debugging through RubyMine
- How do I create a class instance from a string name in ruby?
- In Rails, how to add a new method to String class?
- Why isn’t self always needed in ruby / rails / activerecord?
- Resque vs Sidekiq? [closed]
- How to get class instances in Ruby? [duplicate]
- How to call shell commands from Ruby
- Can you supply arguments to the map(&:method) syntax in Ruby?
- Ruby block and unparenthesized arguments
- Why can I refer to a variable outside of an if/unless/case statement that never ran?
- Is there an efficient way to perform hundreds of text substitutions in Ruby?
- diff a ruby string or array
- Methods in Ruby: objects or not?
- How to break outer cycle in Ruby?
- Difference between DateTime and Time in Ruby
- How does the magic comment ( # Encoding: utf-8 ) in ruby work?
- Need a simple explanation of the inject method
- DRY Ruby Initialization with Hash Argument
- Exporting an Environment Variable in Ruby
- How to get a Date from date_select or select_date in Rails?
- How do I temporarily redirect stderr in Ruby?
- Confusion with Atomic Grouping – how it differs from the Grouping in regular expression of Ruby?
- Extract number from string in Ruby
- Is there a way to remove the BOM from a UTF-8 encoded file?
- Using layouts in HAML files independently of Rails
- How to implement a short URL like the URLs in Twitter?
- How to run untrusted Ruby code inside a safe sandbox?
- ‘||=’ operator in Ruby
- ERROR: Error installing ffi: ERROR: Failed to build gem native extension