Class: SeeingIsBelieving::Binary::Marker
- Inherits:
-
HashStruct
- Object
- HashStruct
- SeeingIsBelieving::Binary::Marker
- Defined in:
- lib/seeing_is_believing/binary/data_structures.rb
Class Method Summary collapse
Instance Method Summary collapse
Methods inherited from HashStruct
#==, #[], #each, #fetch, #hash, #initialize, inspect, #inspect, #key?, #keys, #merge, #pretty_print, #to_hash, #values
Constructor Details
This class inherits a constructor from SeeingIsBelieving::HashStruct
Class Method Details
.to_regex(string) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/seeing_is_believing/binary/data_structures.rb', line 14 def self.to_regex(string) return string if string.kind_of? Regexp flag_to_bit = { 'i' => 0b001, 'x' => 0b010, 'm' => 0b100 } string =~ %r{\A/(.*)/([mxi]*)\Z} body = $1 || string flags = ($2 || "").each_char.inject(0) { |bits, flag| bits | flag_to_bit[flag] } Regexp.new body, flags end |