Module: LiveF1::Enum

Included in:
LiveF1::Event::TrackStatus, LiveF1::Event::Type, Packet::Sys::Weather::Metric
Defined in:
lib/live_f1/enum.rb

Overview

Adds a convenience method for converting between constant values and names

Instance Method Summary collapse

Instance Method Details

#name_for(value) ⇒ Object

Returns the first constant (in definition order) matching the given value



5
6
7
# File 'lib/live_f1/enum.rb', line 5

def name_for value
  constants.detect { |c| const_get(c) == value }
end