Module: Drum

Defined in:
lib/drum.rb,
lib/drum/version.rb,
lib/drum/model/ref.rb,
lib/drum/utils/ext.rb,
lib/drum/utils/log.rb,
lib/drum/model/user.rb,
lib/drum/utils/yaml.rb,
lib/drum/model/album.rb,
lib/drum/model/track.rb,
lib/drum/model/artist.rb,
lib/drum/service/file.rb,
lib/drum/service/mock.rb,
lib/drum/model/raw_ref.rb,
lib/drum/service/music.rb,
lib/drum/service/stdio.rb,
lib/drum/utils/persist.rb,
lib/drum/model/playlist.rb,
lib/drum/service/spotify.rb,
lib/drum/service/applemusic.rb

Defined Under Namespace

Modules: Casings, Log, ToHashById, Try, YAMLUtils Classes: Album, AlbumAppleMusic, AlbumSpotify, AppleMusicService, Artist, ArtistSpotify, CLI, Error, FileService, Logger, MockService, MusicService, PersistentHash, Playlist, PlaylistAppleMusic, PlaylistSpotify, RawRef, Ref, Service, SpotifyService, StdioService, Track, TrackAppleMusic, TrackSpotify, User, UserSpotify

Constant Summary collapse

VERSION =
'0.2.3'

Instance Attribute Summary collapse

Instance Attribute Details

#is_tokenBoolean

Returns Whether the ref is a token (i.e. begins with @).

Returns:

  • (Boolean)

    Whether the ref is a token (i.e. begins with @)



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/drum/model/raw_ref.rb', line 10

RawRef = Struct.new(
  :text,
  :is_token,
  keyword_init: true
) do
  TOKEN_PREFIX = '@'

  # Parses a RawRef from the given string.
  #
  # @param [String] raw The raw string to be parsed
  # @return [RawRef] The parsed RawRef
  def self.parse(raw)
    if raw.start_with?(TOKEN_PREFIX)
      RawRef.new(text: raw.delete_prefix(TOKEN_PREFIX), is_token: true)
    else
      RawRef.new(text: raw, is_token: false)
    end
  end
end

#rawString

Returns The raw text (@-stripped, though, if it’s a token).

Returns:

  • (String)

    The raw text (@-stripped, though, if it’s a token)



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/drum/model/raw_ref.rb', line 10

RawRef = Struct.new(
  :text,
  :is_token,
  keyword_init: true
) do
  TOKEN_PREFIX = '@'

  # Parses a RawRef from the given string.
  #
  # @param [String] raw The raw string to be parsed
  # @return [RawRef] The parsed RawRef
  def self.parse(raw)
    if raw.start_with?(TOKEN_PREFIX)
      RawRef.new(text: raw.delete_prefix(TOKEN_PREFIX), is_token: true)
    else
      RawRef.new(text: raw, is_token: false)
    end
  end
end