jhass changed the topic of #ruby to: Rules & more: https://ruby-community.com | Ruby 2.5.3, 2.4.5, 2.3.8, 2.6.0-preview2: https://www.ruby-lang.org | Paste 4+ lines of text to https://dpaste.de/ and select ruby as the language | Rails questions? Ask in #RubyOnRails | Books: https://goo.gl/wpGhoQ | Logs: https://irclog.whitequark.org/ruby | Can't talk? Register/identify with Nickserv first!
cow[moo] has joined #ruby
orbyt_ has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
mangold has joined #ruby
SeepingN has quit [Quit: The system is going down for reboot NOW!]
jottr has joined #ruby
ta_ has quit [Ping timeout: 252 seconds]
dviola has quit [Quit: WeeChat 2.3]
kentnl has quit [Remote host closed the connection]
eckhardt has quit [Quit: Textual IRC Client: www.textualapp.com]
bak1an has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
kent\n has joined #ruby
apeiros has quit [Remote host closed the connection]
apeiros has joined #ruby
cow[moo] has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
apparition has joined #ruby
apeiros has quit [Ping timeout: 264 seconds]
darkhanb has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
crankharder has quit [Remote host closed the connection]
shoogz has quit [Ping timeout: 264 seconds]
shoogz has joined #ruby
shoogz has joined #ruby
Nicmavr has quit [Read error: Connection reset by peer]
Nicmavr has joined #ruby
despai has quit [Ping timeout: 252 seconds]
jottr has quit [Ping timeout: 252 seconds]
houhoulis has joined #ruby
apeiros has joined #ruby
cthu| has quit [Ping timeout: 264 seconds]
mangold has quit [Quit: This computer has gone to sleep]
tfitts has quit [Quit: Connection closed for inactivity]
apeiros has quit [Ping timeout: 246 seconds]
nowhere_man has joined #ruby
bambanx has quit [Quit: Leaving]
impermanence has quit [Remote host closed the connection]
nadir has joined #ruby
Wojnar has quit [Ping timeout: 272 seconds]
elphe has quit [Ping timeout: 252 seconds]
apeiros has joined #ruby
cthu| has joined #ruby
bak1an has joined #ruby
apeiros has quit [Ping timeout: 246 seconds]
cthu| has quit [Ping timeout: 252 seconds]
Dimik has joined #ruby
Dimik has quit [Excess Flood]
Dimik has joined #ruby
Dimik has quit [Excess Flood]
bak1an has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
darkhanb has joined #ruby
mangold has joined #ruby
pskosinski has quit [Ping timeout: 252 seconds]
pskosinski has joined #ruby
SuperL4g has joined #ruby
nexraf1 has quit [Ping timeout: 250 seconds]
ta_ has joined #ruby
apeiros has joined #ruby
hahuang6- has joined #ruby
apeiros has quit [Ping timeout: 252 seconds]
hahuang65 has quit [Ping timeout: 250 seconds]
dviola has joined #ruby
conceivably has joined #ruby
ta_ has quit [Ping timeout: 245 seconds]
knight33 has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
nchambers has joined #ruby
apeiros has joined #ruby
noobineer has joined #ruby
elphe has joined #ruby
apparition has quit [Quit: Bye]
apeiros has quit [Ping timeout: 246 seconds]
Ekho- is now known as Ekho
braincrash has quit [Quit: bye bye]
braincrash has joined #ruby
nowhere_man has quit [Ping timeout: 252 seconds]
TheBloke has joined #ruby
orbyt_ has joined #ruby
nowhere_man has joined #ruby
eckhardt has joined #ruby
houhoulis has quit [Remote host closed the connection]
dviola has quit [Quit: WeeChat 2.3]
apeiros has joined #ruby
gh0sh- has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
apeiros has quit [Ping timeout: 252 seconds]
dinfuehr has quit [Ping timeout: 245 seconds]
dinfuehr has joined #ruby
xuanrui has joined #ruby
mangold has quit [Quit: This computer has gone to sleep]
nadir has quit [Quit: Connection closed for inactivity]
noobineer has quit [Ping timeout: 264 seconds]
asphyxia has joined #ruby
conceivably has quit [Ping timeout: 272 seconds]
apeiros has joined #ruby
apeiros has quit [Ping timeout: 264 seconds]
scott4000 has quit [Ping timeout: 250 seconds]
nicholaslyang has joined #ruby
j416 has quit [Quit: o/]
j416 has joined #ruby
ivanskie has joined #ruby
noobineer has joined #ruby
mikecmpbll has joined #ruby
jordanm has quit [Remote host closed the connection]
apeiros has joined #ruby
jordanm has joined #ruby
apeiros has quit [Ping timeout: 240 seconds]
ta_ has joined #ruby
ivanskie has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
orbyt_ has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
MoritaShinobu has joined #ruby
apeiros has joined #ruby
elphe has quit [Ping timeout: 252 seconds]
apeiros has quit [Ping timeout: 272 seconds]
elphe has joined #ruby
postmodern has joined #ruby
ta_ has quit [Ping timeout: 264 seconds]
mochiyoda has joined #ruby
xuanrui has quit [Remote host closed the connection]
mikecmpbll has quit [Quit: inabit. zz.]
apeiros has joined #ruby
mochiyoda has quit [Quit: Konversation terminated!]
apeiros has quit [Ping timeout: 264 seconds]
arescorpio has joined #ruby
noobineer has quit [Ping timeout: 240 seconds]
djellemah has quit [Read error: Connection reset by peer]
djellemah has joined #ruby
eb0t has joined #ruby
def_jam has joined #ruby
eb0t_ has quit [Ping timeout: 245 seconds]
eblip has quit [Ping timeout: 252 seconds]
noobineer has joined #ruby
nicholaslyang has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
apeiros has joined #ruby
apeiros has quit [Ping timeout: 246 seconds]
reber has joined #ruby
<nchambers> is there a method like Array::collect except doesn't include nil entries
<nchambers> ah, .compact
<baweaver> Array#collect technically, though Array#map is more common.
<baweaver> map compact is used fairly frequently.
dellavg_ has joined #ruby
n13z_ has quit [Quit: leaving]
<nchambers> thanks
noodle has quit [Quit: /quit]
noodle has joined #ruby
rippa has joined #ruby
TheBloke has quit [Read error: Connection reset by peer]
apeiros has joined #ruby
arescorpio has quit [Quit: Leaving.]
TheBloke has joined #ruby
apeiros has quit [Ping timeout: 240 seconds]
_whitelogger has joined #ruby
ta_ has joined #ruby
whysthatso has joined #ruby
apeiros has joined #ruby
apeiros has quit [Ping timeout: 252 seconds]
ta_ has quit [Ping timeout: 250 seconds]
apeiros has joined #ruby
phaul has joined #ruby
apeiros has quit [Ping timeout: 246 seconds]
armyriad has quit [Quit: Leaving]
anubhav996 has joined #ruby
ta_ has joined #ruby
apeiros has joined #ruby
n13z has joined #ruby
lypsis_ has quit [Quit: ZNC - http://znc.in]
Emmanuel_Chanel has quit [Read error: Connection reset by peer]
armyriad has joined #ruby
Emmanuel_Chanel has joined #ruby
apeiros has quit [Ping timeout: 246 seconds]
lypsis has joined #ruby
def_jam is now known as eblip
postmodern has quit [Quit: Leaving]
conta has joined #ruby
apparition has joined #ruby
voolik has joined #ruby
cd has quit [Quit: cd]
Wojnar has joined #ruby
apeiros has joined #ruby
mikecmpbll has joined #ruby
xfbs has joined #ruby
doubledup has joined #ruby
doubledup has quit [Client Quit]
djellemah has quit [Remote host closed the connection]
cabotto has joined #ruby
mikecmpbll has quit [Quit: inabit. zz.]
elphe has quit [Quit: leaving]
ohcibi_ has quit [Remote host closed the connection]
anubhav996 has quit [Quit: Connection closed for inactivity]
ohcibi has joined #ruby
TheBloke has quit [Read error: Connection reset by peer]
TheBloke has joined #ruby
venmx has joined #ruby
AJA4350 has joined #ruby
cabotto has quit []
nezt0r has joined #ruby
AJA4350 has quit [Client Quit]
AJA4350 has joined #ruby
jottr has joined #ruby
Wojnar has quit [Remote host closed the connection]
TheBloke has quit [Read error: Connection reset by peer]
TheBloke has joined #ruby
voolik has quit [Quit: Taking a nap...]
bkxd has joined #ruby
bier has joined #ruby
whysthatso has left #ruby [#ruby]
whysthatso has joined #ruby
jottr has quit [Ping timeout: 240 seconds]
Nicmavr has quit [Read error: Connection reset by peer]
aufi has joined #ruby
conta has quit [Quit: conta]
Nicmavr has joined #ruby
whysthatso has quit [Quit: whysthatso]
whysthatso has joined #ruby
bkxd has quit [Ping timeout: 246 seconds]
Dimik has joined #ruby
Dimik has quit [Excess Flood]
sidx64 has joined #ruby
Dimik has joined #ruby
Dimik has quit [Excess Flood]
yokel has quit [Remote host closed the connection]
yokel has joined #ruby
DTZUZO has quit [Ping timeout: 246 seconds]
jottr has joined #ruby
ujjain has quit [Ping timeout: 240 seconds]
bmurt has joined #ruby
cyclonis has joined #ruby
phaul has quit [Ping timeout: 240 seconds]
kapil____ has joined #ruby
bkxd has joined #ruby
voolik has joined #ruby
<cyclonis> morning
bkxd has quit [Read error: Connection reset by peer]
voolik has quit [Ping timeout: 276 seconds]
c0ncealed4 has quit [Remote host closed the connection]
c0ncealed4 has joined #ruby
sidx64 has quit [Ping timeout: 252 seconds]
bkxd has joined #ruby
venmx has quit [Ping timeout: 240 seconds]
<cyclonis> :)
<apeiros> moin cyclonis
apeiros has quit [Read error: Connection reset by peer]
apeiros has joined #ruby
bkxd has quit [Read error: Connection reset by peer]
Wojnar has joined #ruby
apeiros has quit [Read error: Connection reset by peer]
phaul has joined #ruby
apeiros has joined #ruby
apeiros has quit [Read error: Connection reset by peer]
apeiros has joined #ruby
bkxd has joined #ruby
thebetrayer has quit [Read error: No route to host]
thebetrayer has joined #ruby
bkxd has quit [Read error: Connection reset by peer]
bmurt has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
conta has joined #ruby
GodFather has joined #ruby
bkxd has joined #ruby
samort7 has joined #ruby
leitz has joined #ruby
bkxd has quit [Read error: Connection reset by peer]
rubydoc has quit [Remote host closed the connection]
rubydoc has joined #ruby
noark9 has joined #ruby
despai has joined #ruby
bkxd has joined #ruby
_whitelogger has joined #ruby
Wojnar has quit [Remote host closed the connection]
Wojnar has joined #ruby
bkxd has quit [Read error: Connection reset by peer]
venmx has joined #ruby
TheBloke has quit [Read error: Connection reset by peer]
queip has joined #ruby
DTZUZO has joined #ruby
knight33 has joined #ruby
DTZUZO has quit [Ping timeout: 240 seconds]
voolik has joined #ruby
im0nde has joined #ruby
asphyxia has quit [Ping timeout: 244 seconds]
roshanavand has joined #ruby
bkxd has joined #ruby
phaul has quit [Read error: Connection reset by peer]
Inline has quit [Quit: Leaving]
phaul has joined #ruby
Wojnar has quit [Remote host closed the connection]
mikecmpbll has joined #ruby
djellemah has joined #ruby
houhoulis has joined #ruby
bkxd has quit [Ping timeout: 246 seconds]
despai has quit [Quit: ...]
Dimik has joined #ruby
Dimik has quit [Excess Flood]
Dimik has joined #ruby
Dimik has quit [Excess Flood]
apparition has quit [Quit: Bye]
samort7 has quit [Read error: Connection reset by peer]
conta has quit [Quit: conta]
venmx has quit [Ping timeout: 272 seconds]
bkxd has joined #ruby
johnny56 has quit [Ping timeout: 272 seconds]
_whitelogger has joined #ruby
Wojnar has joined #ruby
bkxd has quit [Read error: Connection reset by peer]
cow[moo] has joined #ruby
zapata has quit [Read error: Connection reset by peer]
cow[moo] has quit [Client Quit]
zapata has joined #ruby
cow[moo] has joined #ruby
c0ncealed4 has quit [Remote host closed the connection]
c0ncealed4 has joined #ruby
dviola has joined #ruby
bkxd has joined #ruby
orbyt_ has joined #ruby
k0mpa has quit [Ping timeout: 256 seconds]
whysthatso has quit [Quit: whysthatso]
whysthatso has joined #ruby
Inline has joined #ruby
MiLLiYEtCHi has quit []
noark9 has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
bkxd has quit [Ping timeout: 245 seconds]
noark9 has joined #ruby
whysthatso has quit [Remote host closed the connection]
noark9 has quit [Quit: Textual IRC Client: www.textualapp.com]
whysthatso has joined #ruby
noark9 has joined #ruby
MoritaShinobu has quit [Quit: Leaving]
johnny56 has joined #ruby
dviola has quit [Quit: WeeChat 2.3]
conta has joined #ruby
akem__ has joined #ruby
nicholaslyang has joined #ruby
akem has quit [Ping timeout: 272 seconds]
dviola has joined #ruby
c0ncealed4 has quit [Remote host closed the connection]
c0ncealed4 has joined #ruby
bkxd has joined #ruby
bkxd has quit [Read error: Connection reset by peer]
bkxd has joined #ruby
noark9 has quit [Quit: noark9]
eddof13 has joined #ruby
gh0sh- has joined #ruby
eddof13 has quit [Client Quit]
bkxd has quit [Read error: Connection reset by peer]
nicholaslyang has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
bak1an has joined #ruby
bak1an has quit [Client Quit]
knight33 has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
noark9 has joined #ruby
dviola has quit [Quit: WeeChat 2.3]
bkxd has joined #ruby
aufi has quit [Ping timeout: 244 seconds]
bkxd has quit [Read error: Connection reset by peer]
dviola has joined #ruby
kapil____ has quit [Quit: Connection closed for inactivity]
Dimik has joined #ruby
Dimik has quit [Excess Flood]
roshanavand has quit [Quit: leaving]
noark9 has quit [Quit: noark9]
noobineer has quit [Ping timeout: 252 seconds]
bkxd has joined #ruby
kapil____ has joined #ruby
voolik has quit [Quit: Leaving]
rubydoc has quit [Remote host closed the connection]
orbyt_ has quit [Read error: Connection reset by peer]
fusta has joined #ruby
cd has joined #ruby
knight33 has joined #ruby
Wojnar has quit [Remote host closed the connection]
rubydoc has joined #ruby
bkxd has quit [Ping timeout: 245 seconds]
raulp has quit [Ping timeout: 264 seconds]
crankharder has joined #ruby
eddof13 has joined #ruby
eddof13 has quit [Ping timeout: 252 seconds]
orbyt_ has joined #ruby
kaleido has joined #ruby
bkxd has joined #ruby
bkxd has quit [Read error: Connection reset by peer]
bak1an has joined #ruby
bak1an has quit [Ping timeout: 250 seconds]
bkxd has joined #ruby
Puffball has quit [Remote host closed the connection]
Puffball has joined #ruby
bkxd has quit [Read error: Connection reset by peer]
mistergibson has quit [Quit: Leaving]
knight33 has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
nexraf1 has joined #ruby
bkxd has joined #ruby
crankharder has quit [Ping timeout: 245 seconds]
apeiros has quit [Read error: Connection reset by peer]
apeiros has joined #ruby
rubydoc has quit [Remote host closed the connection]
bkxd has quit [Ping timeout: 252 seconds]
jottr has quit [Ping timeout: 244 seconds]
jottr has joined #ruby
bkxd has joined #ruby
xfbs has quit [Quit: afk]
xfbs has joined #ruby
bkxd has quit [Read error: Connection reset by peer]
bkxd has joined #ruby
Wojnar has joined #ruby
bkxd has quit [Read error: Connection reset by peer]
jottr has quit [Ping timeout: 240 seconds]
jottr has joined #ruby
leitz has quit [Quit: Leaving]
Freshnuts has joined #ruby
bkxd has joined #ruby
rubydoc has joined #ruby
uplime has joined #ruby
nchambers has quit [Ping timeout: 264 seconds]
Azure has quit [Ping timeout: 246 seconds]
Azure has joined #ruby
bkxd has quit [Read error: Connection reset by peer]
ta_ has quit [Quit: Leaving...]
whysthatso_ has joined #ruby
whysthatso has quit [Ping timeout: 250 seconds]
whysthatso_ is now known as whysthatso
SCHAPiE has quit [Quit: ZNC - https://znc.in]
Fusl has quit [Ping timeout: 256 seconds]
conta has quit [Quit: conta]
Fusl has joined #ruby
SCHAPiE has joined #ruby
bkxd has joined #ruby
<i8igmac> how can i regex from a capitle letter to a peried
<i8igmac> period*
<i8igmac> data.scan(/[A-Z].*\./)
<canton7> is "to regex" a verb now?
<lupine> sure
<i8igmac> "Start and end of a sentence."
<canton7> oh, so you want to start with a capital letter, followed by a number of other things, and finally a period?
<i8igmac> "So what. Lets talk about it.".scan(/[A-Z]*\./)
<i8igmac> correct
<i8igmac> pulling sentences from large paragraphs
<canton7> so, you want *one* [A-Z], then *zero or more* other things, then *one* period
<canton7> your regex is *zero or more [A-Z], then one period
jacobherrington has joined #ruby
<i8igmac> must have 1 capital letter to start and end with a period
<canton7> yes, you said that
<i8igmac> lol
<canton7> so to step through my sentence above, do you know the regex for "one capital letter"?
jottr has quit [Ping timeout: 246 seconds]
bkxd has quit [Read error: Connection reset by peer]
bkxd has joined #ruby
<i8igmac> i keep trying but i dont know
<i8igmac> scan(/[A-Z]{1}/)
<i8igmac> scan(/[^A-Z]{1}/)
<canton7> Right, or just [A-Z]
<canton7> that's the first capital letter
<canton7> do you know what the regex for "any letter, zero or more times" is?
<i8igmac> * <-lol i suck at thisd
<canton7> that means "zero or more times" yes, but you're missing the "any letter" bit
<i8igmac> (^.*?) maybe
bkxd has quit [Read error: Connection reset by peer]
<canton7> "^" means "the beginning of the string", so you probably don't want that in there
<canton7> (or the beginning of the line, before someone corrects me)
cow[moo] has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<canton7> "." means "any character"
<canton7> and you've already got "a period exactly one time" in your original regex
<canton7> so if you put it all together, you're almost there...
bkxd has joined #ruby
tdy has quit [Ping timeout: 240 seconds]
Wojnar has quit [Ping timeout: 246 seconds]
thebetrayer has quit [Ping timeout: 250 seconds]
dellavg_ has quit [Ping timeout: 252 seconds]
bkxd has quit [Read error: Connection reset by peer]
bkxd has joined #ruby
<apeiros> i8igmac: solved your problem?
<canton7> (there's one final step, which is to stop it matching two sentences together as one match)
<apeiros> >> "So what? Lets talk\nabout it.".scan(/\p{Upper}[^.!?]*[.!?]/)
<ruby[bot]> apeiros: I'm terribly sorry, I could not evaluate your code because of an error: NoMethodError:undefined method `[]' for nil:NilClass
<apeiros> *sob*
<apeiros> well, phaul did rewrite it to use carc. I should get that PR released.
jottr has joined #ruby
<apeiros> > "So what? Lets talk\nabout it.".scan(/\p{Upper}[^.!?]*[.!?]/) # => ["So what?", "Lets talk\nabout it."]
tdy has joined #ruby
<apeiros> I'm not sure using uppercase as an anchor for "beginning of sentence" is a good idea, though. also depending on what it's used on, things like quotation marks should be considered.
rippa has quit [Quit: {#`%${%&`+'${`%&NO CARRIER]
<apeiros> and not every dot is the end of a phrase, e.g. those dots just there aren't.
jacobherrington has quit [Quit: WeeChat 2.2]
orbyt_ has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<canton7> I rather suspect this is a very hard problem for the general case :P
<apeiros> > "So what? Lets talk\nabout e.g. these funny stories.".scan(/\p{Upper}(?:\b\p{L}\.|[^.!?])*[.!?]/) # => ["So what?", "Lets talk\nabout e.g. these funny stories."]
<apeiros> the hardest part is to predict all cases
<apeiros> and there might some cases you simply can't handle with raw regex.
<canton7> yeah, I was thinking that grammar is distinctly non-regulay
<canton7> *non-regular
<apeiros> regulay sounds cromulent.
jottr has quit [Ping timeout: 246 seconds]
tdy1 has joined #ruby
bkxd has quit [Read error: Connection reset by peer]
tdy has quit [Ping timeout: 264 seconds]
Inside has quit [Disconnected by services]
kapil____ has quit [Quit: Connection closed for inactivity]
bkxd has joined #ruby
kurko_ has joined #ruby
bkxd has quit [Read error: Connection reset by peer]
whysthatso has quit [Quit: whysthatso]
kurko_ has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
tdy1 has quit [Ping timeout: 252 seconds]
houhoulis has quit [Remote host closed the connection]
tdy1 has joined #ruby
bkxd has joined #ruby
phaul has quit [Ping timeout: 246 seconds]
kurko_ has joined #ruby
tdy1 has quit [Ping timeout: 245 seconds]
tdy2 has joined #ruby
bkxd has quit [Read error: Connection reset by peer]
Wojnar has joined #ruby
TheBloke has joined #ruby
bkxd has joined #ruby
tdy3 has joined #ruby
tdy2 has quit [Ping timeout: 246 seconds]
bkxd has quit [Read error: Connection reset by peer]
akem has joined #ruby
tdy3 has quit [Ping timeout: 246 seconds]
akem__ has quit [Ping timeout: 252 seconds]
Wojnar has quit [Remote host closed the connection]
tdy3 has joined #ruby
nexraf1 has quit [Ping timeout: 264 seconds]
TheBloke has quit [Read error: No route to host]
lightstalker has quit [Ping timeout: 246 seconds]
TheBloke has joined #ruby
lightstalker has joined #ruby
bkxd has joined #ruby
rubydoc has quit [Remote host closed the connection]
Nicmavr has quit [Read error: Connection reset by peer]
mikecmpbll has quit [Quit: inabit. zz.]
Nicmavr has joined #ruby
rubydoc has joined #ruby
bkxd has quit [Read error: Connection reset by peer]
nadir has joined #ruby
i8igmac has quit [Read error: Connection reset by peer]
DTZUZO has joined #ruby
bkxd has joined #ruby
tdy3 has quit [Ping timeout: 264 seconds]
reber has quit [Remote host closed the connection]
d^sh has quit [Ping timeout: 252 seconds]
kurko_ has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
d^sh has joined #ruby
bkxd has quit [Quit: Lost terminal]
tdy3 has joined #ruby
venmx has joined #ruby
RedNifre has joined #ruby
<RedNifre> Hey there.
<apeiros> hi
cow[moo] has joined #ruby
<RedNifre> I'm trying to write a very simple event system so I do `require 'observer'`, I defined some events as structs i.e. Event_a = Struct.new(:bla), Event_b = Struct.new(:bleh) etc. and I successfully emit them with `changed; notify_observers(event)`, which works, but how do I figure out which event I received?
<RedNifre> Conceptiually, I might have problems because I'm used to statically typed languages.
<RedNifre> I guess Struct.new creates a new class and the observer would have to do something like `when(event.class) case Event_a` or something?
<RedNifre> Writing a switch case for the class? Or am I on the wrong track here?
tdy3 has quit [Ping timeout: 245 seconds]
bmurt has joined #ruby
<apeiros> Struct.new indeed returns a class
<apeiros> but `case event.class when EventA` won't work. you have to use `case event when EventA` (and please, don't call them Event_a, call them EventA, ruby convention is pascal case for this)
<RedNifre> Basically, I'm asking because I want to prevent me writing some crazy code, not knowing how to do it properly.
<apeiros> looking at the docs of observable, it doesn't provide any concepts for message type. so that's up to you.
<RedNifre> Alright, I changed it, I guess I was thinking about variables...
<apeiros> you can do it via the class of the event data, or by a separate parameter - entirely up to you.
<apeiros> *it doesn't +seem+ to…
<RedNifre> Well, doing it via the class of the event data seems natural to me, kinda like an enum or adt.
<apeiros> (I've just glanced over the docs, so I might have missed stuff)
<apeiros> I'd probably rather go via a property of the event, making it more flexible. but as said, it seems to be up to you.
jottr has joined #ruby
<RedNifre> Right now, the structs are on the top level of a .rb file. Can I put them in a group like an enum or ADT?
<RedNifre> (hm... not sure if that would actually acomplish anything...)
<apeiros> adt?
<RedNifre> Algebraic data type
<RedNifre> Like, it's the same type but different constructors yielding different things.
<apeiros> ruby doesn't have enum or adts out of the box. you can construct similarly working things, though.
bmurt has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<apeiros> and while ruby doesn't have constructors, you can have class methods which do a bit of stuff for you.
<RedNifre> For example type Response = OK | Fail(reason: String), where the OK object has no slots, but the Fail instance has one.
<RedNifre> Well, I think it might not help anyways.
<apeiros> ruby is dynamically typed. so you can't enforce something like this in that way.
<apeiros> so the question is - what properties are you looking for?
<RedNifre> It should communicate to the reader that these structs form some group.
<apeiros> would a namespace serve that purpose?
venmx has quit [Ping timeout: 252 seconds]
<RedNifre> Hm!
<RedNifre> how would that look like?
<RedNifre> just module Evenet \ EventA = Struct.new... ?
<apeiros> you can use ; to indicate newlines. that's got the benefit of being even valid.
<apeiros> and yes. that's how it'd look like.
<RedNifre> oh, right :)
<RedNifre> Excellent.
<apeiros> and you can always do; module Evenet; …your structs…; def self.all; [EventA, EventB, …]; end; end`
<apeiros> so Evenet.all will yield a list with all event classes
<apeiros> (though I'd probably require 'set' and return a frozen set)
akem has quit [Quit: Leaving]
<RedNifre> Hm... it's not `module LogEvent; A = Struct.new(...) end ; LogEvent.A.new(...), is it? I'm getting "undefined method `A' for LogEvent:Module" then...
<RedNifre> I meant LogEvent::A.new(...)
<RedNifre> ...or should it be even LogEvent::A::new? Probably not... is "." for methods and "::" for variables? How exactly does :: work?
tdy3 has joined #ruby
orbyt_ has joined #ruby
dviola has quit [Quit: WeeChat 2.3]
Wojnar has joined #ruby
nexraf1 has joined #ruby
kurko_ has joined #ruby
Freshnuts has quit [Quit: Leaving]